我有以下 VBA 宏,它删除 word 文档的标题,然后打印文档,然后将标题添加回来。标题基本上只是一个图像。
问题是每次执行宏时都会在标题中添加一个换行符,这将在一些执行后将主要部分向下移动。
这是我的代码:
Sub print()
Dim oSec As Section
Dim oHead As HeaderFooter
For Each oSec In ActiveDocument.Sections
For Each oHead In oSec.Headers
If oHead.Exists Then oHead.Range.CopyAsPicture
oHead.Range.Delete
Next oHead
Next oSec
ActivePrinter = "Bullzip PDF Printer"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
For Each oSec In ActiveDocument.Sections
For Each oHead In oSec.Headers
If oHead.Exists Then oHead.Range.Paste
Next oHead
Next oSec
End Sub
有人可以解释为什么每次运行宏时都会添加一行吗?