Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exit Sub on Cancel (Word 2003)

    Hi,

    The following codes work fine for me until the user clicks Cancel button.

    ------------------------
    noOfColumn = InputBox("Specify number of columns")

    Do Until (noOfColumn = 3 Or noOfColumn = 4 Or noOfColumn = 7 Or noOfColumn = 8)
    MsgBox "Enter 3 or 4 or 7 or 8", vbExclamation
    noOfColumn = InputBox("Specify number of columns")
    Loop
    -------------------------
    How do I get exit the Sub when the user clicks Cancel?

    Thank you in advance.

    Regards
    Rid

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Exit Sub on Cancel (Word 2003)

    Insert a test to see if the result of InputBox is an empty string "":"

    ...
    noOfColumn = InputBox("Specify number of columns")
    If noOfColumn = "" Then
    Exit Sub
    End If
    ...

  3. #3
    Star Lounger
    Join Date
    Feb 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Exit Sub on Cancel (Word 2003)

    Thank you so much.

Posting Permissions

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