Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Loop without Do error..

Reply
 
Old 06-23-2008   #1 (permalink)
PK


 
 

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 SpecsSystem Spec
Old 06-23-2008   #2 (permalink)
mayayana


 
 

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,
intCol).Value)
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://" &
strGroupDN)
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 SpecsSystem Spec
Old 06-23-2008   #3 (permalink)
PK


 
 

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,
> intCol).Value)
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://" &
> strGroupDN)
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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46