Announcement

Collapse
No announcement yet.

AD Group into Word Error 'loop' without 'do' Word Table

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • AD Group into Word Error 'loop' without 'do' Word Table

    Hi, I am trying to list all groups in active directory into a word document and list them into a word table. but I am getting an error saying Microsoft VBScript compilation error: 'loop' without 'do'

    Please could someone help me with this:


    If objGroup.GroupTypeAND ADS_GROUP_TYPE_SECURITY_ENABLEDThen
        strGroupDesc = strGroupDesc & "Security group"
      Else
        strGroupDesc = strGroupDesc & "Distribution group"
      EndIf

    Set objRange = objDoc.Range()
    objDoc.Tables.Add objRange,1,4
    Set objTable = objDoc.Tables(1)

     x=1

    ForEach objItemin colItems
        If x > 1Then
            objTable.Rows.Add()
        EndIf
        
      
      err.clear
      arrMemberOf = objGroup.GetEx("Member") 
      If Err.Number = E_ADS_PROPERTY_NOT_FOUNDthen
        
        objTable.Cell(x, 1).Range.Text = strGroupName
        objTable.Cell(x, 2).Range.text = strGroupDesc
        objTable.Cell(x, 3).Range.text = "<null>"
        objTable.Cell(x, 4).Range.text = "<null>"
        x = x + 1
      Else
        
        ForEach strMemberOfin arrMemberOf
          Set objMember = GetObject("LDAP://" & strMemberOf) 
          strMemberName = right(objMember.Name,len(objMember.Name)-3) 
          
          objTable.Cell(x, 1).Range.Text = strGroupName
        objTable.Cell(x, 2).Range.text = strGroupDesc
        objTable.Cell(x, 3).Range.text = strMemberName
        objTable.Cell(x, 4).Range.text = objMember.Class
        x = x + 1
          Set objMember = nothing
          
        Next
      EndIf
      objRecordSet.MoveNext
      Set objGroup = nothing
    Loop  

  • #2
    Re: AD Group into Word Error 'loop' without 'do' Word Table

    Precisely as the error says, your script ends with "LOOP" without beginning it with a matching "DO"

    Looking at it, LOOP in the last line may actually be "NEXT" to end the first FOR EACH block, which otherwise doesn't have an end

    Can you give a source for the original script please?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: AD Group into Word Error 'loop' without 'do' Word Table

      Thank you for your reply, I have added a next into the script and that has stopped the error, but the table is not being added. If I change the table to write a line into word it works.

      Comment

      Working...
      X