Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Test InputBox for Cancel?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred Holmes - 01 Nov 2004 17:05 GMT
How Does one test whether the user has pressed Cancel on an input box?

myString = InputBox(. . . .

If myString = vbCancel Then Exit Sub

The above fails.  Pressing Cancel does not trigger the if statement.

MS Word 2003
Jay Freedman - 01 Nov 2004 17:31 GMT
> How Does one test whether the user has pressed Cancel on an input box?
>
[quoted text clipped - 5 lines]
>
> MS Word 2003

Hi Fred,

Use
   If myString = ""
or
   If Len(myString) = 0

There's no way in an InputBox to distinguish between hitting the Cancel
button and simply leaving the box blank and hitting OK. Usually there's no
reason to need that distinction. If you do need it, use a userform instead
of an InputBox -- that also has the advantage that the user can fill in
multiple items and only click OK once.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.