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