2013-09-25 4 views
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() 
} 

답변

0

각 구 Word 파일을 추가하기 전에 새 Word 파일에 새 섹션을 시작하는 것이 할 수 있습니다. Word 문서의 각 섹션에는 고유 한 머리글/바닥 글이있을 수 있습니다. 그러나 새 머리글/바닥 글을 독립적으로 지정하지 않으면 이전 머리글/바닥 글이 변경됩니다. 그것을 수동으로 먼저 수행하십시오.

방금 ​​깨달은 것입니다. 이것은 비슷한 문제로 어제 들었던 것과 기본적으로 동일합니다.

관련 문제