关于用C#操作WORD文档的问题? 就是用C#在WORD文档插入一个换页符后,如何让当前光标位置定位到刚插入的那页??这样我插入的OLE对象就能够插入到刚插入的那个页了?郁闷,搞了几天都没搞定。用代码操作的时候插入的OLE对象总是放在第一页,而放不到插入的新页面?总是感觉用C#代码操作WORD的页很麻烦,没发现相关的关于页的函数和属性。反而POWERPOINT好点,有个SLIDES集合,一个SLIDE就是一页。那位有经验的出来指点下迷津,在WORD如何操作这个页面 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有操作过也许有SetTextFocus、SetSelectStart、SetSelectText之类的方法,属性设置之类 你可以设置一个标签,每次插入的时候都插入到这个标签的后面object oMissing = System.Reflection.Missing.Value;object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined book *///Start Word and create a new document.Word._Application oWord;Word._Document oDoc;oWord = new Word.Application();oWord.Visible = true;oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);//Insert a paragraph at the beginning of the document.Word.Paragraph oPara1;oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);oPara1.Range.Text = "Heading 1";oPara1.Range.Font.Bold = 1;oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.oPara1.Range.InsertParagraphAfter();//Insert a paragraph at the end of the document.Word.Paragraph oPara2;object oRng = oDoc.Books.get_Item(ref oEndOfDoc).Range;oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);oPara2.Range.Text = "Heading 2";oPara2.Format.SpaceAfter = 6;oPara2.Range.InsertParagraphAfter();这也是从别处找来的,不知道对你有没有用 PDF填充问题 [Diamond制作]组团行动,挖掘自己! 使用C#操作Excel文件时,如何根据表名来选择一个表? 水晶报表winform下用pull模式,报表预览时字段内容可以显示,运行时就显示不了,是怎么回事啊 如何建立智能客户端 急急急 C#怎么将unicode编码的字符串转换成GB2312编码的变量? 即使数据刷新问题??? 哪里有有关pattern(设计模式)的书籍的下载 如果我的程序最小化为一个notifyicon。。。我想用shift+z+x使其最大化。如何实现? 有关图形方面的问题,? 请教一段xml的写法。 如何判断一个字符串是符合命名规则?
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined book *///Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);//Insert a paragraph at the beginning of the document.
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = "Heading 1";
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();//Insert a paragraph at the end of the document.
Word.Paragraph oPara2;
object oRng = oDoc.Books.get_Item(ref oEndOfDoc).Range;
oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
oPara2.Range.Text = "Heading 2";
oPara2.Format.SpaceAfter = 6;
oPara2.Range.InsertParagraphAfter();
这也是从别处找来的,不知道对你有没有用