Word文書のヘッダーを削除し、文書を印刷してからヘッダーを追加する次のVBAマクロがあります。ヘッダーは基本的に画像のみです。
問題は、マクロが実行されるたびにヘッダーに改行が追加され、いくつかの実行後にメイン セクションが下に移動することです。
ここに私が持っているコードがあります:
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
マクロが実行されるたびに追加の行が追加される理由を誰か説明できますか?