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.

Setting caption for a messagebox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter - 21 Nov 2005 22:01 GMT
Hello,

How can I modify this code to set a caption in my message box, I seem to get
a compile error every time I try:
MsgBox(prompt:=strOption1, Buttons:=vbYesNo)

strOption1 is a string varible that has been pre defined.

Thanks,
Peter
Jay Freedman - 22 Nov 2005 02:44 GMT
>Hello,
>
[quoted text clipped - 6 lines]
>Thanks,
>Peter

I think your problem is not with the prompt, rather that you're using
parentheses around the parameters but you aren't assigning the
function result to anything. Try writing

 nResult = MsgBox(prompt:=strOption1, Buttons:=vbYesNo)

where nResult is declared as an Integer. Alternatively, you can
implicitly use the function result in a logical statement:

  If MsgBox(prompt:=strOption1, Buttons:=vbYesNo) = vbYes Then
   ' ...
  End If

When you use MsgBox as a subroutine (not returning a value), then you
must omit the parentheses:

  MsgBox prompt:="This is my message"

See http://www.word.mvps.org/FAQs/MacrosVBA/BracketsWithArgmnts.htm
for an explanation.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Peter - 22 Nov 2005 19:46 GMT
Hi Jay,

I am now using :

Response = MsgBox(prompt:=strOption1, Buttons:=vbYesNo)

How do I get the title in the title bar of the message box to display
something other than the default (Word).

Thanks,
Peter  

> >Hello,
> >
[quoted text clipped - 34 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
Charles Kenyon - 22 Nov 2005 20:29 GMT
Set the Title property as well.
, Title:="This is my message box. Please read!"
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.

> Hi Jay,
>
[quoted text clipped - 47 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
Peter - 22 Nov 2005 21:01 GMT
Thanks Charles,

That Worked!

> Set the Title property as well.
> , Title:="This is my message box. Please read!"
[quoted text clipped - 49 lines]
> >> Email cannot be acknowledged; please post all follow-ups to the
> >> newsgroup so all may benefit.

Rate this thread:






 
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.