C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
来源:互联网 发布:淘宝知识产权被投诉3次 编辑:程序博客网 时间:2024/05/24 15:36
1、Microsoft.Office.Interop.Word.Application wordApp =new ApplicationClass()
word对象
2、 Microsoft.Office.Interop.Word.Document wordDoc = wordApp.Documents.Add(ref Nothing,ref Nothing, ref Nothing,ref Nothing) 文档对象
3、 Object Nothing = System.Reflection.Missing.Value常用的一个参数
4、wordApp.ActiveWindow.ActivePane.View.SeekView =WdSeekView.
wdSeekCurrentPageHeader定位到页眉
5、 wordApp.Selection.ParagraphFormat. Borders[WdBorderType.wdBorderBottom]
.LineStyle = WdLineStyle.wdLineStyleNone去掉页眉线
6、wordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument跳出页眉
7、 wordApp.Selection.ParagraphFormat.Alignment =WdParagraphAlignment.
wdAlignParagraphCenter对齐方式(此为居中)
8、 Microsoft.Office.Interop.Word.Table policyTab = wordDoc.Tables.Add
(wordApp.Selection.Range, 行数, 列, ref Nothing, ref Nothing);创建表格
9、 wordApp.Selection.GoTo(ref oGoToItem,ref oGoToLast, ref Nothing,ref Nothing);定位页面(此为将光标定位到内容的最后)
10、 wordApp.Selection.InsertBreak(ref Nothing);插入分节符
11、 wordApp.Selection.InsertFile(nofile, ref Nothing, ref contenFalse, ref contenFalse, ref contenFalse);插入文件
12、 wordApp.Selection.InlineShapes.AddPicture(picName,ref LinkToFile, ref SaveWithDocument,ref Nothing);插入图片
13、 wordApp.ActiveWindow.ActivePane.View.SeekView =WdSeekView.
wdSeekCurrentPageFooter;定位到页脚
14、 wordApp.Selection.TypeText("此处写需要在指定位置输出的文字");文本输入
15、 wordDoc.ComputeStatistics(WdStatistic.wdStatisticPages,ref Nothing);得到页码
16、 wordDoc.PrintOut(ref Nothing,ref Nothing, ref Nothing,ref Nothing,
ref Nothing,ref Nothing, ref Nothing,ref Nothing,
ref Nothing,ref Nothing, ref Nothing,ref Nothing,
ref Nothing,ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing);
调用打印机实现打印(调用的是默认打印机)
17、 wordDoc.Close(ref saveChanges,ref Nothing, ref Nothing);文档退出
18、 wordApp.Quit(ref Nothing,ref Nothing, ref Nothing);word程序退出
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- C# word中插入页脚而不要页眉横线
- word插入页眉图片
- word 页眉 插入图片
- Word页眉页脚教程:删除页眉横线的方法
- word去掉页眉或页脚的横线
- word中插入页眉页脚
- 用word 2003制作毕业论文从正文开始加页码的页眉页脚,去掉页眉横线
- word中插入横线
- word 插入一条横线
- word 插入一条横线
- word页眉横线去除方法
- Word 2013中任意页插入页眉页脚的方法
- word插入空白页且使得页码连续且没有页眉和页脚的方法
- 如何去掉Word页眉下面的那条横线
- 去掉页眉横线三法 (WORD)
- WORD中如何去掉页眉中的横线
- 禁止输入指定字符
- 国人制作的 Chrome 浏览器语音输入扩展 Voice Input
- C#操作word
- IIS7 url里面禁止包含bin的文件夹
- ubuntu下使用vi退出终端出现乱码的解决方案
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- 单链表的一些常用操作
- 解释执行与编译执行
- matplotlib学习之(四)设置线条颜色、形状
- msvcr80.dll和msvcr80d.dll共存问题
- SPI协议简介
- 同步容器,并发容器(java并发编程实践读书笔记一)
- ArcGIS Runtime SDKs介绍以及简单的实例
- (转)天嵌QT程序开发手册第六章出现的问题