Microsoft KB Archive/925183

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:33, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


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

Article ID: 925183

Article Last Modified on 10/15/2007



APPLIES TO

  • Microsoft Office Word 2007



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


Additional query words: wd2007 wd12 wd2k7 Word2007 Word12 Word2k7 2k7 12 VB VBA C# C+ Macro

Keywords: kbtshoot kbregistry kbformat kbprogramming kbprb kbcode kbexpertiseinter KB925183