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?

Answers


var document = Globals.ThisDocument.InnerObject;

PlainTextContentControl plainTextControl = Controls.AddPlainTextContentControl(
document.ActiveWindow.Selection.Range, "ptcc1");

works for me in word 2010 - so no guarantee! :)

cheerz


Need Your Help

How to display table from SQLite database in QTableView widget?

c++ qt sqlite qt5

I created a SQLite database called "test.db". It has only one table called "table1" which is not an empty table.

AngularJS Formdata file array upload

java angularjs servlets form-data

I'm trying to upload (actually POST) numerous small files in one go along with some key, value pairs: