Msg Box at end of Macro

  • Thread starter Thread starter Karin
  • Start date Start date
K

Karin

Hi,

I'd like to put a message box at the end of a macro indicating that the
macro ran. Can someone help me, I keep getting compile errors.
(Expected =)

MsgBox(prompt:="Verbiage Changed", Buttons:=vbOkOnly, Title:="Finished")

TIA!
 
Leave out the parenthesis:

MsgBox Prompt:="Verbiage Changed", Buttons:=vbOKOnly, Title:="Finished"

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
Karin said:
Hi,

I'd like to put a message box at the end of a macro indicating that
the macro ran. Can someone help me, I keep getting compile errors.
(Expected =)

MsgBox(prompt:="Verbiage Changed", Buttons:=vbOkOnly,
Title:="Finished")

TIA!

Just remove the parentheses, leaving a space between MsgBox and prompt.

The explanation (sort of) is at
http://www.word.mvps.org/FAQs/MacrosVBA/BracketsWithArgmnts.htm. By
including parentheses around the parameter list, you're implying to VBA that
it's a function (part 2 of the article), and a function has to be on the
right side of an equal sign so that its return value can be put somewhere.
That's why it says it's expecting an equal sign.

Because you aren't using any return value, you're calling MsgBox as a sub
(part 3 of the article), which means you shouldn't have parentheses.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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

Back
Top