0

I have to make some Word Integration as part of an exam project. My problem is that I am rather new to Microsoft Word integration in C#. I have the Assemblies I need, and I got everything set-up ready to write code pretty much. The document will be generated from scratch.

But I am just starring at the blinking cursor, not really knowing how to start.

I have to take a StringBuilder (which should hold stuff like escape characters for new lines, perhaps italic bold, etc kind of formatting as well.) The StringBuilder will be given from another part of the application written by my friend.

Would you suggest that this is delivered in another form than a StringBuilder Object?

And where should I start with all this? It's a bit overwhelming.

Thanks

4

1 回答 1

0

尝试这个

您需要添加 Microsoft.Office.Interop.Word 参考

Word._Application oWord;
Word._Document oDoc;
object oMissing = Type.Missing;
oWord = new Word.Application();
oWord.Visible = true;

//Add Blank sheet to Word App
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); 

oWord.Selection.TypeText("Write your text here");
//FOrmatting your text
oWord.Selection.Font.Size = 8;
oWord.Selection.Font.Name = "Zurich BT";
oWord.Selection.Font.Italic = 1
oWord.Selection.Font.Bold = 1

oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = //Havent tested the  
                                                             //header and footer part
Word.WdSeekView.wdSeekCurrentPageFooter;
oDoc.Content.Application.Selection.TypeText(“Martens”);

我想这可能是你正在寻找的

于 2013-04-18T09:50:00.807 回答