I am having a problem with a new script I am writing(I have tabled the active directory script for the moment). It will eventually list all the groups in our exchange schema and all users per group in a excel spreadsheet. Right now when I run the script all I want is each sheet in the workbook to be named after the group it represents. The result I get from the following script is that it changes the name of the first sheet and creates all the other sheets, but does not rename them. Any ideas what is wrong with my script?
Thank you everyone in advance for the help.
Roger
Code:
Dim g_iCounter, g_oSheet, g_oExcel, oGroupObj
call Main()
Function Main()
g_iCounter = 0
Set g_oExcel = CreateObject("Excel.Application")
g_oExcel.Workbooks.Add
set oGroupObj = GetObject("LDAP://OU=GROUPS,OU=TEST,DC=TESTSVR,DC=COM")
for each oGroup in oGroupObj
g_iCounter=g_iCounter + 1
g_oExcel.ActiveWorkbook.Worksheets.Add
Set g_oSheet = g_oExcel.ActiveWorkbook.Worksheet (g_iCounter)
g_oSheet.Cells(1,1).Font.Size = 12
g_oSheet.Cells(1,1).Font.Bold = True
g_oSheet.Range("A1:H1").Interior.Color = RGB(100,100,100)
g_oSheet.Cells(1,1).Value = "Group Name: " & oGroup.Name
g_oSheet.Name = oGroup.Name
next
g_oExcel.ActiveWorkbook.SaveAs "c:\all email groups dump.xls"
g_oExcel.ActiveWorkbook.Close
End Function
Thank you everyone in advance for the help.
Roger