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 2005

Tip: Looking for answers? Try searching our database.

MsgBox for beginners - Help please!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kastnna - 04 Nov 2005 19:25 GMT
I am new to VB and am having a little trouble. I want to write the
script so that a msgbox will open that ask a YesNo question. Clicking
yes will produce one answer in "textfield9" and clicking no will
produce a different answer in the same text field.

Thanks in advance
Greg - 04 Nov 2005 19:46 GMT
I am assuming that textfield9 is a formfield bookmark name.n  Try
something like:

Sub ScratchMacro()
If MsgBox("Do you like beer?", vbYesNo, "Question") = vbYes Then
 ActiveDocument.FormFields("textField9").Result = "Have one on me."
Else
 ActiveDocument.FormFields("textField9").Result = "Ok, I'll have one
myself."
End If
End Sub
Charles Kenyon - 04 Nov 2005 19:48 GMT
Try writing some code and if it doesn't work, post it here and someone will
help you with it.
http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

In vba help, review the Input Box. (A Message Box doesn't collect
information from the user, just provides it to the user.)

Unless you want the user to be able to change it in the document, you
probably want to set a bookmark for your location in the document, and when
running your procedure unprotect the document, insert your information in
the bookmark, reprotect the document without resetting fields and then
continue. http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm 
In talking about protecting and unprotecting the document, I am assuming
that this is a document protected for forms - because of your field name.
This is what Word calls an "online form." Check this in help. For more about
online forms, follow the links at
http://addbalance.com/word/wordwebresources.htm#Forms or
http://word.mvps.org/FAQs/Customization/FillinTheBlanks.htm especially Dian
Chapman's series of articles. You may also want to look at
http://www.word.mvps.org/FAQs/TblsFldsFms/LinesInForms.htm.

Finally, rather than an input box (which calls for a text answer) you may
want a UserForm on which you can put checkboxes or drop-down menus. It is
well worth your time to learn to use UserForms because they are very
powerful and flexible.
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm Ms. Chapman's later
articles discuss these as well.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

>I am new to VB and am having a little trouble. I want to write the
> script so that a msgbox will open that ask a YesNo question. Clicking
> yes will produce one answer in "textfield9" and clicking no will
> produce a different answer in the same text field.
>
> Thanks in advance
kastnna - 04 Nov 2005 20:01 GMT
thanks for the help guys!
 
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.