O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Line Continuation

The very nature of Word VBA syntax often leads to long lines of code, which can be difficult to read, especially if we need to scroll horizontally to see the entire line. For this reason, Microsoft recently introduced a line-continuation character into VBA. This character is the underscore (_), which must be preceded by a space and cannot be followed by any other characters (including comments). For example, the following code:

	ActiveDocument.Paragraphs(1).Alignment = _
	wdAlignParagraphCenter

is treated as one line by Word.

A line-continuation character cannot be inserted in the middle of a literal string constant, which is enclosed in quotation marks.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required