就是用C#在WORD文档插入一个换页符后,如何让当前光标位置定位到刚插入的那页??这样我插入的OLE对象就能够插入到刚插入的那个页了?郁闷,搞了几天都没搞定。用代码操作的时候插入的OLE对象总是放在第一页,而放不到插入的新页面?总是感觉用C#代码操作WORD的页很麻烦,没发现相关的关于页的函数和属性。反而POWERPOINT好点,有个SLIDES集合,一个SLIDE就是一页。那位有经验的出来指点下迷津,在WORD如何操作这个页面

解决方案 »

  1.   

    没有操作过也许有SetTextFocus、SetSelectStart、SetSelectText之类的方法,属性设置之类
      

  2.   

    你可以设置一个标签,每次插入的时候都插入到这个标签的后面
    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();
    这也是从别处找来的,不知道对你有没有用