ContentControl's formatting leaks outside control
I'm developing application level add-in plugin to Word 2007. Unlucky I've encountered minor problem with styling dynamically added content:
I've created Content control, and changed it's style with following code:
PlainTextContentControl plainTextControl = extendedDocument.Controls.AddPlainTextContentControl( currentDocument.ActiveWindow.Selection.Range,"ptcc1"); plainTextControl.Text = "hello world"; plainTextControl.Range.Font.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Color.LightGray); plainTextControl.Range.Borders.Enable = (int)WdLineStyle.wdLineStyleSingle; plainTextControl.LockContents = true;
It works - inserted text control has border and gray background, but when i type text just after inserted element this style persist - newly typed characters are bordered and with background color as well. How to limit formatting changes to ContentControl only?
var document = Globals.ThisDocument.InnerObject; PlainTextContentControl plainTextControl = Controls.AddPlainTextContentControl( document.ActiveWindow.Selection.Range, "ptcc1");
works for me in word 2010 - so no guarantee! :)