Windows Vista Forums

Loop without Do error..
  1. #1


    PK Guest

    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

  2. #2


    mayayana Guest

    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...


    > 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

  3. #3


    PK Guest

    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:

    >
    > 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...
    >
    >

    > > 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

Loop without Do error.. problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
BHO DLL error causing rebooting loop fantomas General Discussion 5 21 Sep 2009
Unknown Logging Off Loop Error Keitaro Tsugaru System Security 1 26 May 2009
Error Recovey Loop zoomzoomam General Discussion 13 19 Oct 2008
Critical error loop gah Vista General 3 03 Jun 2008
Windows Explorer error loop bstrader1 General Discussion 2 29 Apr 2008