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);
版权声明:本文标题:C#Word常用代码段 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1726312269h934632.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论