0
此代碼創建一些帶有不同頁眉和頁腳的文件。 我希望他們合併成一個與保存有頁眉和頁腳 我該怎麼辦,在PowerShell中保留頁眉頁腳,同時將多個doc文件合併爲一個
$val=ls $dir
set-variable -name wdAlignPageNumberCenter -value 1
foreach ($file in $val){
$Word = New-Object -ComObject Word.Application
$Word.Visible = $true
$Doc = $Word.Documents.Add()
$Section = $Doc.Sections.Item(1)
$Header = $Section.Headers.Item(1)
$Footer = $Section.Footers.Item(1)
$Footer.PageNumbers.Add($wdAlignPageNumberCenter)
****some code******
$filedata = (get-content $filename)
$Footer.Range.Text=$page
$head="$abcd`t`tFile ID: $file"
$Header.Range.Text = $head
$line_count = 0
***some code*******
$savepath="D:\$file.docx"
$Doc.SaveAs([ref]$savepath)
$Doc.Close()
}