• Exit Sub on Cancel (Word 2003)

    Author
    Topic
    #417510

    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

    Viewing 0 reply threads
    Author
    Replies
    • #936940

      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

    Viewing 0 reply threads
    Reply To: Exit Sub on Cancel (Word 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: