首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

在C#中怎么设置word文档中,一段文字的样式

2012-01-14 
在C#中如何设置word文档中,一段文字的样式在C#中如何设置word文档中,一段文字的样式[解决办法]先通过录制

在C#中如何设置word文档中,一段文字的样式
在C#中如何设置word文档中,一段文字的样式

[解决办法]
先通过录制宏得到相应的VBA代码
察看Word VBA帮助中对应方法的说明, 再转换成C#
[解决办法]
可以看看vsto方面的书
[解决办法]
答案 ls的两位已经说了
[解决办法]
VSTO好像没有这方面的内容,能不能给段代码。或网站链接
[解决办法]
// Create an instance of Word, make it visible,
// and open Doc1.doc.
Word.ApplicationClass oWord = new Word.ApplicationClass();
oWord.Visible = true;
Word.Documents oDocs = oWord.Documents;
object oFile = "c:\\doc1.doc ";

// If the Microsoft Word 10.0 Object Library is referenced
// use the following code.
Word._Document oDoc = oDocs.Open(ref oFile, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing);

// If the Microsoft Word 11.0 Object Library is referenced comment
// the previous line of code and uncomment the following code.
//Word._Document oDoc = oDocs.Open(ref oFile, ref oMissing,
//ref oMissing, ref oMissing, ref oMissing, ref oMissing,
//ref oMissing, ref oMissing, ref oMissing, ref oMissing,
//ref oMissing, ref oMissing, ref oMissing, ref oMissing,
//ref oMissing, ref oMissing);

// Run the macros.
RunMacro(oWord, new Object[]{ "DoKbTest "});
RunMacro(oWord, new Object[]{ "DoKbTestWithParameter ",
"Hello from C# Client. "});

// Quit Word and clean up.
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
System.Runtime.InteropServices.Marshal.ReleaseComObject (oDoc);
oDoc = null;
System.Runtime.InteropServices.Marshal.ReleaseComObject (oDocs);
oDocs = null;
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
System.Runtime.InteropServices.Marshal.ReleaseComObject (oWord);
oWord = null;

break;

[解决办法]
http://support.microsoft.com/kb/306683/zh-cn

热点排行