Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If Then Else not working (VBA for Word 2000)

    The following is an excerpt of code from the ATTACHED document. I'm having problems with an If/Then/Else. After running through several paragraphs the Else should be activated, but it is not. The "less than (<)" should be false when K=UBound(ListFormatArray, 1), but it is showing as true. Thanks for any help you can give!! Troy

    For K = 1 To UBound(ListFormatArray, 1)
    'CHECK OUT THESE VALUES. AFTER THE FIRST RUN THROUGH THEY ARE EQUAL.
    MsgBox UBound(ListFormatArray, 1)
    MsgBox K
    If ExistingNumberStyle <> ListFormatArray(K, 1) Or _
    ExistingNumberFormat <> ListFormatArray(K, 2) Or _
    ExistingParagraphIndent <> ListFormatArray(K, 3) Then
    If FirstRowInArray = True Then
    GoTo MoveToFirstRowInArray
    End If
    'THIS IS THE LINE OF CODE THAT DOES NOT SEEM TO WORK. AS YOU CAN SEE _
    FROM THE MESSAGE BOXES ABOVE, K=1 and UBound(ListFormatArray, 1)=1 _
    SO THE "IF" SHOULD GO TO THE "ELSE", BUT THE IF IS COMING ACROSS AS TRUE.
    If K < UBound(ListFormatArray, 1) Then
    End If
    Else
    Attached Files Attached Files

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Then Else not working (VBA for Word 2000)

    You have the End If immediately after the If. That terminates that If statement, and the Else after that End If goes with the first In in the code you showed. Since there are no statements in the If to execute, it is tough to know if the condition was True or False.
    Legare Coleman

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If Then Else not working (VBA for Word 2000)

    Believe it or not, the problem was another "End If" that I had commented out. If found it after moving a large block of code within this procedure to its own procedure.

    I hate it when it's something simple.

    Thanks for responding!!
    Troy <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •