![]() |
![]() OCAU News - Wiki - QuickLinks - Pix - Sponsors |
|
|||||||
| Notices |
|
Sign up for a free OCAU account and this ad will go away! Search our forums with Google: |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Member
Join Date: Oct 2007
Posts: 178
|
Hey guys,
In need of a little help with a script i have created, and i want to add a little more error checking into it, i have an explore box to find a spreadsheet to take names etc from and put them into active directory but when i want to press cancel on my explore box it continues in the script, id prefer it it just jumped to the bottom of my case statement rather than go to the next step, and i cant for the life of me figure out how to make it do that. can anyone please help? Script follows; Case 2 on error resume next 'Read Excel sheet Set objDialog = CreateObject("SAFRCFileDlg.FileOpen") objDialog.OpenFileOpenDlg Set objExcel = CreateObject("Excel.Application") 'Initialise Excel Set objWorkbook = objExcel.Workbooks.Open _ ( objDialog.FileName ) ' Open file intRow = 3 'Start at third row of spreadsheet WhiOU = InputBox("Please enter which OU you would like to add the users to") Do Until objExcel.Cells(intRow,1).Value = "" Set objOU = GetObject("LDAP://ou=" & WhiOU & ",dc=tafe,dc=local") ' Define OU, domain Set objUser = objOU.Create _ ("User", "cn=" & objExcel.Cells(intRow, 2).Value) objUser.sAMAccountName = objExcel.Cells(intRow, 1).Value objUser.GivenName = objExcel.Cells(intRow, 3).Value objUser.SN = objExcel.Cells(intRow, 4).Value objUser.Department = objExcel.Cells(intRow, 6).value objUser.SetInfo objUser.AccountDisabled = FALSE objUser.SetInfo objUser.SetPassword objExcel.Cells(intRow, 5).value 'Set password to the data in column 5 'Set department to the data in column 6 intRow = intRow + 1 'Move to next row if err.number then wscript.Echo "Error creating users - Error in looped procedure." err.Clear wscript.Quit End if Loop if err.number then wscript.Echo "Error creating users." err.Clear End if 'Close spreadsheet handling objExcel.Quit Thanks guys
__________________
Main Rig - Intel Core 2 Quad Q6600 G0 @ 3.2GHz // Asus P5Q Premium // 4GB Corsair Dominators // Leadtek GTX260+ Extreme // Seasonic 700w Modular // NZXT Tempest Case // 2.4TB of storage Selling RAM and P4 PC's - http://forums.overclockers.com.au/sh...d.php?t=806186 |
|
|
|
| Join OCAU to remove this ad! |
![]() |
| Bookmarks |
| Tags |
| script, server, server03 |
|
Sign up for a free OCAU account and this ad will go away! |
| Thread Tools | |
|
|