Updated code: executes the script but nothing does output and the Excel.exe process continues to run. I Directory it needs to produce to .vbs script was launched from and Excel Book1.xls
options clearly something other than dim strFile, strGroupDN, objGroup, objExcel, intRow, objMember File name, ObjSheet dim objRootDSE, strDNSDomain, objTrans, strNETBIOSDomain, strGroup const ADS_NAME_INITTYPE_GC = 3 const ADS_NAME_TYPE_NT4 = 3 set ADS_NAME_TYPE_1779 = 1 set objRootDSE = GetObject ("LDAP: // RootDSE") strDNSDomain = objRootDSE.Get ("defaultNamingContext") Set objTrans = CreateObject ("NameTranslate") objTrans.Init ADS_NAME_INITTYPE_GC, "objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain strNetBIOSDomain = objTrans.Get (ADS_NAME_TYPE_NT4) strNetBIOSDomain = Left (strNetBIOSDomain, _LAN (strNetBIOSDomain) - 1) strGroup = Enter InputBox ( "AD group name") resume error Next objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & amp; "\" & Amp; StrGroup if (Err.Number & lt; & gt; 0) then error Wscript.Echo "Group" & amp; Go on the GoTo Group & amp; "Not Found" Wscript.Quit finally strGroupDN = objTrans.Get (ADS_NAME_TYPE_1779) set objGroup = GetObject ( "LDAP: //" & amp; strGroupDN) set objExcel = CreateObject ( "Excel.Application") objExcel.Workbooks.Add objExcel . Column (1) .ColumnWidth = 100 set objSheet = objExcel.ActiveWorkbook.Worksheets (1) objSheet.Name = "Ad group member" intRow = 1 objMember in objMember for objSheet.Cells (intRow, 1) .Value = objMember .sAMAccountName intRow = intRow + 1 Next set FSO = CreateObject ( "Scripting.FileSystemObject") CWD = fso.GetAbsolutePathName ( "*. *") filename = fso.BuildPath (CWD, "output.xls") objExcel.ActiveWorkbook .SaveAs file name
is a method; So change
objExcel.ActiveWorkbook.SaveAs = ThisWorkbook.Path the
objExcel.ActiveWorkbook.SaveAs ThisWorkbook. Path On the second thought: Where does this workbook come from? WRT updated code: There is a difference between you:
cwd = fso.GetAbsolutePathName ("*. *") and of Ansgar:
cwd = fso GetAbsolutePathName (".") < p> uses to get the script folder (as opposed to the current directory as) fso.GetParentFolderName (WScript.ScriptFullName)
No comments:
Post a Comment