我现在用代码控制导出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();
这个是我控制焦点下移到紧跟上一内容的地方,我想从这个地方直接换到下一页,顶者有分
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();
这个是我控制焦点下移到紧跟上一内容的地方,我想从这个地方直接换到下一页,顶者有分
{
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();
}
object count = 1;
Doc.ActiveWindow.Selection.GoTo(ref what, ref Nothing, ref count, refNothing);//移到当前焦点的下一页
另外 建议楼主先在word里面录制宏 然后看vb宏代码 借鉴之
object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
object count = 1;
Doc.ActiveWindow.Selection.MoveDown(ref what, ref count,refNothing);
你查一下 MSDN 中的 Doc.ActiveWindow.Selection.MoveDown 方法
类似 13#那样用 具体怎么样查一下吧
楼主用 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);//移到当前焦点到文档第一页//我以前做过 现在搞忘记了 反正就是类似这样做的 不好意思 呵呵