Sub
BearbeiteWordDatei(filePath
As
String
, templateDocPortrait
As
Document, templateDocLandscape
As
Document)
Dim
doc
As
Document
Dim
orientation
As
String
Dim
rngTmp
As
Range
Dim
template
As
Document
Dim
headFoot
As
HeaderFooter
Set
doc = Documents.Open(filePath)
orientation = doc.PageSetup.orientation
With
doc.Sections(1).Footers(wdHeaderFooterPrimary)
Select
Case
doc.PageSetup.orientation
Case
wdOrientPortrait
Set
template = templateDocPortrait
Case
wdOrientLandscape
Set
template = templateDocLandscape
End
Select
Set
headFoot = template.Sections(1).Footers(wdHeaderFooterPrimary)
headFoot.Range.Copy
.Range.Paste
While
.Range.StoryLength > headFoot.Range.StoryLength
Set
rngTmp = .Range
rngTmp.Start = rngTmp.
End
- 1
rngTmp.Delete
Wend
End
With
doc.Save
doc.Close SaveChanges:=
False
Set
doc =
Nothing
End
Sub