Sub
Spendenbeleg_Geld()
Dim
wordapp
As
New
Word.Application
Dim
doc
As
Word.Document
Dim
Zeile
As
Long
Dim
rw
As
Range
Worksheets(
"Kassenbuch"
).Activate
wordapp.Visible =
True
Set
doc = wordapp.Documents.Open(
"C:\Users\49151\Documents\Ö\04_Freizeit\_StSebSchützen\Vorlagen\Spendenbescheinigung\Spendenbescheinigung_Geld.docx"
)
For
Each
rw
In
Selection.Rows
Zeile = rw.Row
doc.FormFields(
"Betrag"
).Result = Tabelle1.Cells(Zeile, 5)
With
doc.Bookmarks(
"Name"
).Range
.Text = Tabelle1.Cells(Zeile, 20).Value
.Bookmarks.Add
"Name"
End
With
With
doc.Bookmarks(
"Straße"
).Range
.Text = Tabelle1.Cells(Zeile, 22).Value
.Bookmarks.Add
"Straße"
End
With
With
doc.Bookmarks(
"Hausnummer"
).Range
.Text = Tabelle1.Cells(Zeile, 23).Value
.Bookmarks.Add
"Hausnummer"
End
With
With
doc.Bookmarks(
"Wohnort"
).Range
.Text = Tabelle1.Cells(Zeile, 21).Value
.Bookmarks.Add
"Wohnort"
End
With
With
doc.Bookmarks(
"Datum"
).Range
.Text = Tabelle1.Cells(Zeile, 2).Value
.Bookmarks.Add
"Datum"
End
With
doc.SaveAs2 ThisWorkbook.Path &
"\20xx-xx-xx_Geldspende_Geber_"
& Tabelle1.Cells(Zeile, 9).Value &
".docx"
Next
rw
doc.Close SaveChanges:=
False
wordapp.Quit
End
Sub