![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Loop without Do error.. Dear all Hope someone can help ive got a "Loop Without Do" error on line 316. and i cant see why.. Line 316 is the last Loop Statement in the below code. kr Paul '260-------------------------------------------------------------------- ' Group DN's start in column 12. intCol = 8 Do While objSheet.Cells(intRow, intCol).Value <> "" strGroupDN = Trim(objSheet.Cells(intRow, intCol).Value) ' Attempt to bind to group object DN. blnBound = False On Error Resume Next Set objGroup = GetObject("LDAP://" & strGroupDN) If (Err.Number <> 0) Then On Error GoTo 0 '365 Try again converting NT Name to DN. On Error Resume Next objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain _ & "\" & strGroupDN If (Err.Number <> 0) Then On Error GoTo 0 Wscript.Echo "Unable to bind to group " & strGroupDN Else On Error GoTo 0 strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779) Set objGroup = GetObject("LDAP://" & strGroupDN) blnBound = True End If Else On Error GoTo 0 blnBound = True End If If (blnBound = True) Then objGroup.Add objUser.AdsPath If (Err.Number <> 0) Then On Error GoTo 0 Wscript.Echo "Unable to add user " & strNTName _ & " to group " & strGroupDN End If End If On Error GoTo 0 ' Increment to next group DN. intCol = intCol + 1 Loop End If End If End If '308--------------------------------------------- ' Increment to next user. intRow = intRow + 1 ' ... In the loop. ' Add new user to the group. objGroup.Add oNewUser.AdsPath Loop Wscript.Echo "Done" ' Clean up. objExcel.ActiveWorkbook.Close objExcel.Application.Quit Set objUser = Nothing Set objGroup = Nothing Set objContainer = Nothing Set objSheet = Nothing Set objExcel = Nothing Set objFSO = Nothing Set objShell = Nothing Set objTrans = Nothing Set objRootDSE = Nothing |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Loop without Do error.. Well, you do have two Loops and one Do in the code you posted, so that doesn't doesn't provide much of a clue. ![]() If the Do/Loops check out then look for unmatched If/End If in that section of code. The debugger gets confused when counting If/End If with Do... With... For... Quote: > Hope someone can help ive got a "Loop Without Do" error on line 316. and i > cant see why.. > > Line 316 is the last Loop Statement in the below code. > > kr > > Paul > > '260-------------------------------------------------------------------- > > ' Group DN's start in column 12. > > intCol = 8 > Do While objSheet.Cells(intRow, intCol).Value <> "" > strGroupDN = Trim(objSheet.Cells(intRow, Quote: > ' Attempt to bind to group object DN. > blnBound = False > On Error Resume Next > Set objGroup = GetObject("LDAP://" & strGroupDN) > If (Err.Number <> 0) Then > On Error GoTo 0 > '365 Try again converting NT Name to DN. > On Error Resume Next > objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain _ > & "\" & strGroupDN > If (Err.Number <> 0) Then > On Error GoTo 0 > Wscript.Echo "Unable to bind to group " & > strGroupDN > Else > On Error GoTo 0 > strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779) > Set objGroup = GetObject("LDAP://" & Quote: > blnBound = True > End If > Else > On Error GoTo 0 > blnBound = True > End If > If (blnBound = True) Then > objGroup.Add objUser.AdsPath > If (Err.Number <> 0) Then > On Error GoTo 0 > Wscript.Echo "Unable to add user " & strNTName Quote: > & " to group " & strGroupDN > End If > End If > On Error GoTo 0 > ' Increment to next group DN. > intCol = intCol + 1 > > > Loop > End If > End If > End If > > '308--------------------------------------------- > > ' Increment to next user. > intRow = intRow + 1 > > ' ... In the loop. > ' Add new user to the group. > objGroup.Add oNewUser.AdsPath > Loop > > Wscript.Echo "Done" > > ' Clean up. > > objExcel.ActiveWorkbook.Close > objExcel.Application.Quit > Set objUser = Nothing > Set objGroup = Nothing > Set objContainer = Nothing > Set objSheet = Nothing > Set objExcel = Nothing > Set objFSO = Nothing > Set objShell = Nothing > Set objTrans = Nothing > Set objRootDSE = Nothing > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Loop without Do error.. cheers yes the loops added up but i was missing an endif oh if they were all this easy... think ive been hacking at this one for too long now..! pk "mayayana" wrote: Quote: > > Well, you do have two Loops and one Do in > the code you posted, so that doesn't doesn't > provide much of a clue. ![]() > > If the Do/Loops check out then look for unmatched > If/End If in that section of code. The debugger gets > confused when counting If/End If with Do... With... For... > > Quote: > > Hope someone can help ive got a "Loop Without Do" error on line 316. and i > > cant see why.. > > > > Line 316 is the last Loop Statement in the below code. > > > > kr > > > > Paul > > > > '260-------------------------------------------------------------------- > > > > ' Group DN's start in column 12. > > > > intCol = 8 > > Do While objSheet.Cells(intRow, intCol).Value <> "" > > strGroupDN = Trim(objSheet.Cells(intRow, Quote: > > ' Attempt to bind to group object DN. > > blnBound = False > > On Error Resume Next > > Set objGroup = GetObject("LDAP://" & strGroupDN) > > If (Err.Number <> 0) Then > > On Error GoTo 0 > > '365 Try again converting NT Name to DN. > > On Error Resume Next > > objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain _ > > & "\" & strGroupDN > > If (Err.Number <> 0) Then > > On Error GoTo 0 > > Wscript.Echo "Unable to bind to group " & > > strGroupDN > > Else > > On Error GoTo 0 > > strGroupDN = objTrans.Get(ADS_NAME_TYPE_1779) > > Set objGroup = GetObject("LDAP://" & Quote: > > blnBound = True > > End If > > Else > > On Error GoTo 0 > > blnBound = True > > End If > > If (blnBound = True) Then > > objGroup.Add objUser.AdsPath > > If (Err.Number <> 0) Then > > On Error GoTo 0 > > Wscript.Echo "Unable to add user " & strNTName Quote: > > & " to group " & strGroupDN > > End If > > End If > > On Error GoTo 0 > > ' Increment to next group DN. > > intCol = intCol + 1 > > > > > > Loop > > End If > > End If > > End If > > > > '308--------------------------------------------- > > > > ' Increment to next user. > > intRow = intRow + 1 > > > > ' ... In the loop. > > ' Add new user to the group. > > objGroup.Add oNewUser.AdsPath > > Loop > > > > Wscript.Echo "Done" > > > > ' Clean up. > > > > objExcel.ActiveWorkbook.Close > > objExcel.Application.Quit > > Set objUser = Nothing > > Set objGroup = Nothing > > Set objContainer = Nothing > > Set objSheet = Nothing > > Set objExcel = Nothing > > Set objFSO = Nothing > > Set objShell = Nothing > > Set objTrans = Nothing > > Set objRootDSE = Nothing > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| BHO DLL error causing rebooting loop | General Discussion | |||
| Error Recovey Loop | General Discussion | |||
| method Error in foreach loop | PowerShell | |||
| Critical error loop | Vista General | |||
| Installation Error Loop. Stumped. | Vista installation & setup | |||