Cancelling out of Input Boxes

S

Sophia

Hello:
I am working on a macro in Word, where I have input boxes
for the user to enter text. I am working in labels and
have 4 input box function in each label so that they uer
can enter the desired information. The input boxes contain
and "OK" button and a "Cancel" When you have more than
one input box in a macro, when you click on "Cancel" it
doesn't let you exit out, instead it just goes to the next
input box.

I have tried to put in
If string = vbcancel then End End If

But that doesn't work.


I have also tried to use the cancel property by:
string.cancel = true
and then if string = true exit. But that doesn't work.

I read online that vbvancel really is a numeric character
that equals 2, which is why vbcancel doesn't work.

So my question is:
How do you get the "Cancel" or "X" button on the input box
to work?

I am fairly new at this so I could be overlooking
something.
Any help would be appreciated.

Also can you update a cell before you move onto the next
cell when you are working with labels??

Thanks,
Sophia
(e-mail address removed)
..
 
J

Jonathan West

Hi Sophia,

The InputBox function returns an empty string "" if you cancel out of it.

There is no way to distinguish between clicking CAncel, and clicking OK
without entering any text.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
I

Isbjornen

This is what I've used to get out: Set som type
of "password" for exiting the code, such as "out". When
the code reads it from the inputbox, it exits.

If Ucase(string)= "OUT" then Exit Sub

The Ucase() is only to make sure all characters are the
same.

Isbjornen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top