Hey folks,
I'm creating an MS Word document in a C# Windows application. Because the
client base has so many different versions of Word they are using, I opted
to go with late binding to create the document.
**Everything works great, but I can't figure out how to do 2 things:
1) Double Spacing
2) Insert a Page Break
Here's some snippet of code to help you see how I am doing it (This creates
the document, makes it visible, sets the font size, sets it to bold, and
writes out some text):
Type WordType = Type.GetTypeFro mProgID("Word.A pplication");
Object WordApp = Activator.Creat eInstance(WordT ype);
WordType.Invoke Member("Visible ", BindingFlags.Se tProperty, null, WordApp,
new object[]{true});
Object WordDoc = WordApp.GetType ().InvokeMember ( "Documents" ,
BindingFlags.Ge tProperty, null, WordApp, null );
WordDoc = WordDoc.GetType ().InvokeMember ( "Add", BindingFlags.In vokeMethod,
null, WordDoc, null );
Object WordSelection = WordApp.GetType ().InvokeMember ( "Selection" ,
BindingFlags.Ge tProperty, null, WordApp, null );
Object WordFont = WordSelection.G etType().Invoke Member( "Font",
BindingFlags.Ge tProperty, null, WordSelection, null );
WordType.Invoke Member("Size", BindingFlags.Se tProperty, null, WordFont, new
object[]{10});
WordType.Invoke Member("Bold", BindingFlags.Se tProperty, null, WordFont, new
object[]{true});
WordType.Invoke Member("TypeTex t", BindingFlags.In vokeMethod, null,
WordSelection, new object[]{"MY WONDERFUL TEXT"});