Help and Support

Article ID: 925183 - Last Review: October 15, 2007 - Revision: 1.2

The formatting of text is reset to plain text when you try to determine character formatting programmatically in Word 2007

Expand all | Collapse all

SYMPTOMS

You try to determine programmatically whether the text at the cursor uses bold, italic, or underline character formatting in Microsoft Office Word 2007. When you do this, the type of character formatting is correctly identified.

However, after the formatting is determined programmatically, the formatting of the text that was tested is reset to plain text formatting. Additionally, the Bold, the Italic, or the Underline button in the Font group on the Home tab is no longer selected.

You might try again to determine programmatically what the character formatting is for the same text. When you do this, the formatting is again identified as the original formatting (bold, italic, or underlined). However, the current formatting is plain text.

CAUSE

This issue occurs when the code that is used to determine the type of character formatting uses the Range property of the Selection object. When you use the Range property to determine the type of character formatting of a range of text, the character formatting for that text is reset to plain text when the code finishes running.

WORKAROUND

To work around this issue, set the DontResetInsertionPointProperties application property to "true" only when you use the Range property to determine the type of character formatting for a range of text. Do not use this property globally within your code. The DontResetInsertionPointProperties property should be used only in direct conjunction with the Range property.

An example of this code is as follows:
   Application.DontResetInsertionPointProperties = True

' Format testing code segment

   Application.DontResetInsertionPointProperties = False

APPLIES TO
  • Microsoft Office Word 2007
Keywords: 
kbtshoot kbregistry kbformat kbprogramming kbprb kbcode kbexpertiseinter KB925183

Article Translations

 

Related Support Centers