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

Range and Selection Object Properties and Methods

Now that you know how to create or change a Range or Selection object, we will look at some of the properties and methods of these objects that might prompt you to create the object in the first place.

The Text and TextRetrievalMode Properties

As expected, the Text property returns or sets the text in the specified range or selection. In conjunction with this property, you may want to set the TextRetrieval-Mode property. This property returns a TextRetrievalMode object, whose properties in turn affect how text is retrieved using the Text property. Note that the Text-RetrievalMode property applies only to the Range object, not the Selection object.

The TextRetrievalMode object has three interesting properties that affect text retrieval. The Boolean IncludeHiddenText property should be set to True to retrieve hidden text along with the ordinary nonhidden text. The Boolean Include-FieldCodes property should be set to True to retrieve field codes along with the text. Finally, the ViewType property can be set to any one of the constants in the following enum:

	Enum WdViewType
	   wdNormalView = 1
	   wdOutlineView = 2
	   wdPageView = 3
	   wdPrintPreview = 4
	   wdMasterView = 5
	   wdOnlineView = 6
	End Enum

Note that setting the ViewType property does not affect the view of the text on the screen. It is used only to determine what text will be retrieved by the Text property. For instance, if the ViewType property is set to wdOutlineView, then only the text that ...

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