WD: Using MsgBox Statement to Display Multiple Lines of Text

ID: Q81788

The information in this article applies to:

SUMMARY

In Microsoft Word, you can use the MsgBox command to post a message or the value of a variable. This article discusses how to display more than one line of text within a message box.

MORE INFORMATION

To post more than one line of information, you use character 13 or "Chr$(13)", to insert a paragraph mark within the message box.

The following macro command posts the contents of the variables strRed, strGreen and strBlue on separate lines of a message box:

      MsgBox strRed + Chr$(13) + strGreen + Chr$(13) + strBlue

Assuming the contents of the variables equate to Red, Green, and Blue, the above macro command results in a message box that displays the following lines of text:

   Red
   Green
   Blue

If the text you want to display is of numeric value, you can use the Str$() function to return the string representation. For example, the following macro posts the numbers 1 and 2, on seperate lines, in a message box:

   MsgBox Str$(1) + Chr$(13) + Str$(2)

The following macro command demonstrates the use of character 13 to display two lines of literal text in a message box:

      MsgBox "Line One of the message box." + Chr$(13) + "Line Two."

This macro command results in a message box that displays the following lines of text:

   Line One of the message box.
   Line Two.

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 257

Additional query words: new line Chr$ MsgBox message box

Keywords          : kbmacro wordnt kbmacroexample word8 kbwordvba winword ntword macword word6 winword2 word7 word95 
Version           : WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a,97; MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform          : MACINTOSH Win95 WINDOWS winnt
Issue type        : kbhowto kbinfo

Last Reviewed: November 8, 1998