在C#中如何设置word文档中,一段文字的样式 在C#中如何设置word文档中,一段文字的样式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先通过录制宏得到相应的VBA代码察看Word VBA帮助中对应方法的说明, 再转换成C# 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 下载的时候怎么弹出选择路径 vs2005的在生成控制台应该程序时出错? 求复制数据表记录的嵌套算法 读数据和写数据问题 请教高人!!1 我写的一个简繁转换的Web Service程序(源代码) 在C#里面引用COM组件的问题 Help!关于numericUpDown的问题,各位请帮忙! 请问怎么定义一组数组? 帮帮我 求教图像保存相对地址的问题,在线,高手花一分钟帮帮忙 PrimaryKey
察看Word VBA帮助中对应方法的说明, 再转换成C#
// 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;