admin 管理员组

文章数量: 887021

            //打开word
            MSWord.Application WordApp = new MSWord.Application();
            object oMissing = System.Reflection.Missing.Value;
            object filename = @"C:\Users\Administrator\Desktop\201.doc";
            MSWord.Document WordDoc = WordApp.Documents.Open(ref filename,
            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);
            //文件保存
            object filename = @"C:\202.doc";
            WordDoc.SaveAs(ref filename, 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);
            WordDoc.Close(ref oMissing, ref oMissing, ref oMissing);
            WordApp.Quit(ref oMissing, ref oMissing, ref oMissing); 
            //移动到下一页
            MSWord.WdGoToItem goPage = MSWord.WdGoToItem.wdGoToPage;
            WordApp.Selection.GoToNext(goPage);
            object objWhat = MSWord.WdGoToItem.wdGoToPage;
            object objWhich = MSWord.WdGoToDirection.wdGoToLast;
            //跳转最后一页
            WordApp.Selection.GoTo(ref objWhat, ref objWhich, ref oMissing, ref oMissing);
            //跳转最后一行
            objWhat = MSWord.WdGoToItem.wdGoToLine;
            WordApp.Selection.GoTo(ref objWhat, ref objWhich, ref oMissing, ref oMissing);

本文标签: 常用 代码 Word