fkt_ReplaceBookmarkTextRange ActiveDocument,
"SpalteOben"
,
"SpalteUnten"
Function
fkt_ReplaceBookmarkTextRange(oDoc
As
Document, strBMName1
As
String
, strBMName2
As
_
String
)
Dim
rng1
As
Range, rng2
As
Range
Dim
xlAppl
As
Object
Dim
xlWbk
As
Object
Dim
xlWks
As
Object
strPathAndFile = "PFAD“
Set
xlAppl = CreateObject(
"Excel.Application"
)
Set
xlWbk = xlAppl.Workbooks.Open(FileName:=strPathAndFile)
xlAppl.Visible =
False
Set
xlWksTest = xlWbk.Worksheets(
"Test"
)
If
oDoc.Bookmarks.Exists(strBMName1)
Then
Set
rng1 = oDoc.Bookmarks(strBMName1).Range
Set
rng2 = oDoc.Bookmarks(strBMName2).Range
xlWksTest.Range(
"B175:B191"
).Copy
oDoc.Range(rng1.Start, rng2.
End
).Paste
oDoc.Bookmarks.Add Name:=strBMName2, Range:=rng2
Set
rng1 =
Nothing
Set
rng2 =
Nothing
End
If
End
Function