word vba在当前光标下一页插入A4横页,并设置页边距,插入的A4横页下一页设置A4纵向
时间: 2023-08-07 19:11:58 浏览: 72
可以使用以下代码实现:
```
Sub InsertPage()
'插入A4横向页并设置页边距
Selection.InsertBreak Type:=wdSectionBreakContinuous
ActiveDocument.PageSetup.Orientation = wdOrientLandscape
With ActiveDocument.PageSetup
.LeftMargin = CentimetersToPoints(1.27)
.RightMargin = CentimetersToPoints(1.27)
.TopMargin = CentimetersToPoints(1.27)
.BottomMargin = CentimetersToPoints(1.27)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.27)
.FooterDistance = CentimetersToPoints(1.27)
End With
'跳到下一页并设置为A4纵向页
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext
Selection.InsertBreak Type:=wdSectionBreakContinuous
ActiveDocument.PageSetup.Orientation = wdOrientPortrait
With ActiveDocument.PageSetup
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.TopMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.27)
.FooterDistance = CentimetersToPoints(1.27)
End With
End Sub
```
这段代码首先在当前光标下一页插入一个 A4 横向页,并设置页边距为 1.27cm。然后跳到下一页并插入一个 A4 纵向页,并设置页边距为 2.54cm。你可以根据需要自行调整页边距和纸张方向。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)