Sub
excel2word()
Dim
a
Dim
x
Dim
Kundenname = .Worksheets(
"Stammdaten"
).Range(
"B1"
)
With
Worksheets(
"LVZ_Vertrag"
)
For
x = 1
To
30
If
.Cells(x, 1).text =
"x"
Then
a = .Cells(x, 2).text
Next
x
End
With
Dim
appWord
As
Object
Dim
doc
As
Object
On
Error
Resume
Next
Set
appWord = GetObject(,
"Word.Application"
)
If
Err.Number <> 0
Then
Set
appWord = CreateObject(
"Word.Application"
)
appWord.Visible =
True
appWord.Activate
Set
doc = appWord.Documents.Open(
"C:\Users\agxmbl\Desktop\LVZ_Test.docx"
)
doc.Bookmarks(
"Test0"
).Range.text = a
doc.Bookmarks(
"Test1"
).Range.text = a
doc.Bookmarks(
"Test2"
).Range.text = a
End
Sub