我现在用代码控制导出word,我想控制焦点下移到下一页应该怎么做
 Object countUse = listOfUse.Count + 2;
                        object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;
                        WordApp.Selection.MoveDown(ref WdLine, ref countUse, ref Nothing);
                        WordApp.Selection.TypeParagraph();
这个是我控制焦点下移到紧跟上一内容的地方,我想从这个地方直接换到下一页,顶者有分

解决方案 »

  1.   

     private void ExportExcel(string str,bool type)
            {
                Response.Buffer = true;
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.Charset = "gb2312";
                if (type)
                {
                    Page.Response.AddHeader("Content-Disposition", "filename=ExportFile.xls");
                    Page.Response.ContentType = "application/vnd.ms-excel"; //输出类型application/msword为word格式
                }
                else
                {
                    Page.Response.AddHeader("Content-Disposition", "filename=ExportFile.doc");
                    Page.Response.ContentType = "application/msword"; //输出类型application/msword为word格式
                }
                Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                Page.Response.Write(str);
                Page.Response.End();
            }
      

  2.   

     object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
     object count = 1;
    Doc.ActiveWindow.Selection.GoTo(ref what, ref Nothing, ref count, refNothing);//移到当前焦点的下一页
    另外 建议楼主先在word里面录制宏  然后看vb宏代码  借鉴之
      

  3.   

    不好意思  写错了  
    object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
     object count = 1;
    Doc.ActiveWindow.Selection.MoveDown(ref what, ref count,refNothing);
      

  4.   

     Selection.InsertBreak Type:=wdPageBreak我试过了,VB代码是这么写,怎么转成C#呢
      

  5.   

    也看下   操作word
      
     
      

  6.   


    你查一下 MSDN 中的 Doc.ActiveWindow.Selection.MoveDown 方法
    类似 13#那样用  具体怎么样查一下吧
      

  7.   


    楼主用 Goto试一下object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
    object count = 1;  //自己设置第几页
    object which = wdGoToAbsolute;
    object Nothing = System.Reflection.Missing.Value;
    Doc.ActiveWindow.Selection.GoTo(ref what, ref which, ref count, ref Nothing);//移到当前焦点到文档第一页//我以前做过  现在搞忘记了  反正就是类似这样做的  不好意思  呵呵
      

  8.   

    object which = wdGoToAbsolute;这一句编译通不过,没从Word里找到,你是用C#写的吗,这个编译通不过呀