word修改页边距/纸张纵向/装定线等vba代码
时间:2022-12-09 17:24:43
本文将介绍一些VBA代码来实现页面的页边距、纸张纵向、装定线、页眉页静等,感兴趣的你可以参考下,希望这些VBA代码可以帮助到你下面的WAPP是事先定义的word文档工程变量。
以下代码为通过VBA代码来实现页面的页边距、纸张纵向、装定线、页眉页静等。
复制代码代码如下:
WApp.ActiveDocument.PageSetup.LineNumbering.Active =0;//行编号
WApp.ActiveDocument.PageSetup.Orientation =Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;//页面方向
WApp.ActiveDocument.PageSetup.TopMargin =WApp.CentimetersToPoints(float.Parse("2.54"));//上页边距
WApp.ActiveDocument.PageSetup.BottomMargin = WApp.CentimetersToPoints(float.Parse("2.54"));//下页边距
WApp.ActiveDocument.PageSetup.LeftMargin = WApp.CentimetersToPoints(float.Parse("3.17"));//左页边距
WApp.ActiveDocument.PageSetup.RightMargin = WApp.CentimetersToPoints(float.Parse("3.17"));//右页边距
WApp.ActiveDocument.PageSetup.Gutter = WApp.CentimetersToPoints(float.Parse("0"));//装订线位置
WApp.ActiveDocument.PageSetup.HeaderDistance = WApp.CentimetersToPoints(float.Parse("1.5"));//页眉
WApp.ActiveDocument.PageSetup.FooterDistance = WApp.CentimetersToPoints(float.Parse("1.75"));//页脚
WApp.ActiveDocument.PageSetup.PageWidth = WApp.CentimetersToPoints(float.Parse("21"));//纸张宽度
WApp.ActiveDocument.PageSetup.PageHeight = WApp.CentimetersToPoints(float.Parse("29.7"));//纸张高度
WApp.ActiveDocument.PageSetup.FirstPageTray = Microsoft.Office.Interop.Word.WdPaperTray.wdPrinterDefaultBin;//纸张来源
WApp.ActiveDocument.PageSetup.OtherPagesTray = Microsoft.Office.Interop.Word.WdPaperTray.wdPrinterDefaultBin;//纸张来源
WApp.ActiveDocument.PageSetup.SectionStart = Microsoft.Office.Interop.Word.WdSectionStart.wdSectionNewPage;//节的起始位置:新建页
WApp.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = 0;//页眉页脚-奇偶页不同
WApp.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = 0;//页眉页脚-首页不同
WApp.ActiveDocument.PageSetup.VerticalAlignment = Microsoft.Office.Interop.Word.WdVerticalAlignment.wdAlignVerticalTop;//页面垂直对齐方式
WApp.ActiveDocument.PageSetup.SuppressEndnotes =0;//不隐藏尾注
WApp.ActiveDocument.PageSetup.MirrorMargins = 0;//不设置首页的内外边距
WApp.ActiveDocument.PageSetup.TwoPagesOnOne = false;//不双面打印
WApp.ActiveDocument.PageSetup.BookFoldPrinting =false;//不设置手动双面正面打印
WApp.ActiveDocument.PageSetup.BookFoldRevPrinting =false;//不设置手动双面背面打印
WApp.ActiveDocument.PageSetup.BookFoldPrintingSheets = 1;//打印默认份数
WApp.ActiveDocument.PageSetup.GutterPos = Microsoft.Office.Interop.Word.WdGutterStyle.wdGutterPosLeft;//装订线位于左侧
WApp.ActiveDocument.PageSetup.LinesPage = 40;//默认页行数量
WApp.ActiveDocument.PageSetup.LayoutMode = Microsoft.Office.Interop.Word.WdLayoutMode.wdLayoutModeLineGrid;//版式模式为“只指定行网格”
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
如何用键盘调整WORD字体大小
![](https://img.aspxhome.com/file/2023/5/19205_0s.jpg)
iOS16有哪些新功能?iOS16有哪些BUG?
![](https://img.aspxhome.com/file/2023/1/45321_0s.png)
Word中2007版进行设置标题样式的操作技巧
如何删除word文档中的属性和个人信息
![](https://img.aspxhome.com/file/2023/8/17808_0s.png)
word在哪里插入符号?word插入符号方法
![](https://img.aspxhome.com/file/2023/2/23382_0s.jpg)
Word文档快速转换为PPT幻灯片的技巧
![](https://img.aspxhome.com/file/2023/0/28930_0s.jpg)
Word如何用好段落编号?word自动编号的那些事儿
![](https://img.aspxhome.com/file/2023/8/23938_0s.jpg)
win10鼠标轨迹特效如何关闭
![](https://img.aspxhome.com/file/2023/1/48301_0s.jpg)
PPT2019文本编辑有什么技巧 Office2019 PPT找不到发布命令的解决方法
![](https://img.aspxhome.com/file/2023/5/15065_0s.jpg)
Word文档中随心所欲添加页码的技巧
![](https://img.aspxhome.com/file/2023/2/22392_0s.jpg)
word2010公式功能,帮你轻松设计公式
![](https://img.aspxhome.com/file/2023/2/21402_0s.jpg)
word2013怎么设置页面布局呢?
![](https://img.aspxhome.com/file/2023/8/25358_0s.jpg)
如何关闭Win10系统的Office助手?
![](https://img.aspxhome.com/file/2023/8/49388_0s.png)
捷速ocr文字识别软件怎么修改扫描图片上的文字?
![](https://img.aspxhome.com/file/2023/6/15256_0s.png)
word制作复杂表格的方法步骤详解
Word文档怎么设何止图表公式的自动编号?
![](https://img.aspxhome.com/file/2023/7/28787_0s.jpg)
Word的软回车是什么
Win10输入法如何进行设置?教你轻松设置win10输入法
![](https://img.aspxhome.com/file/2023/8/48938_0s.jpg)
如何在word中自动生成目录页码及目录页码怎么设置
![](https://img.aspxhome.com/file/2023/1/18581_0s.jpg)
Word2007:表格底纹设置技巧
![](https://img.aspxhome.com/file/2023/9/25269_0s.jpg)