Word Vba修改页边距.纸张纵向.装定线等的代码
时间:2023-12-13 17:46:20
下面的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)
猜你喜欢
Mac端这个软件可以帮你找出重复照片:PowerPhotos
![](https://img.aspxhome.com/file/2023/4/a209164_0s.png)
Word中进行设置纸张和文档网格的操作方法
win10应用商店更新错误0x80073D02该怎么办?
![](https://img.aspxhome.com/file/2023/28/a246381_0s.jpg)
Win10怎么关闭语音识别功能?Win10关闭语音识别功能的操作方法
![](https://img.aspxhome.com/file/2023/8/52808_0s.png)
轻松调整Windows 7任务栏预览窗大小
![](https://img.aspxhome.com/file/2023/27/a234377_0s.jpg)
熊猫吃短信如何使用?熊猫吃短信使用方法
![](https://img.aspxhome.com/file/2023/8/a337533_0s.jpg)
讯飞输入法快捷短语在哪里
win10远程控制其他电脑时怎么设置自定义分辨率?
![](https://img.aspxhome.com/file/2023/28/a250794_0s.jpg)
Win7玩穿越火线老是出现蓝屏怎么办
![](https://img.aspxhome.com/file/2023/2/a286178_0s.jpg)
WPS excel在数据前面批量添加字母
![](https://img.aspxhome.com/file/2023/3/a185113_0s.png)
如何翻录 DVD 并将其复制到 Mac?
![](https://img.aspxhome.com/file/2023/2/a204932_0s.jpeg)
Excel中2010版自动填充工作日日期的操作技巧
如何截取PDF文档中的部分内容
![](https://img.aspxhome.com/file/2023/9/a342570_0s.jpg)
excel2003基本操作方法
Win7系统收藏夹不能用怎么办?Win7系统收藏夹不能用的解决方法
![](https://img.aspxhome.com/file/2023/27/a230167_0s.jpg)
PPT中怎么制作笔墨效果?
![](https://img.aspxhome.com/file/2023/10/a346674_0s.jpg)
MacBook如何进入/user目录文件夹?
![](https://img.aspxhome.com/file/2023/9/a202929_0s.jpeg)
word页面高度怎么设置
![](https://img.aspxhome.com/file/2023/5/35695_0s.jpg)
Mac新手注意,这2个屏幕锁定方式了解下
![](https://img.aspxhome.com/file/2023/1/a203971_0s.jpeg)
win10截图快捷键保存在哪里?
![](https://img.aspxhome.com/file/2023/25/a217508_0s.jpg)