Sub
Zahlen_hinzufügen()
Dim
intRowCnt
As
Integer
Dim
AppWD
As
Object
Dim
fn
Dim
wdDoc
As
Object
Const
StartDrive =
"C:"
Const
StartDir = "\"
ChDrive StartDrive
ChDir StartDir
fn = Application.GetOpenFilename(
"Word-Dokumente, *.docx"
, ,
"Bitte Datei auswählen"
)
If
fn =
False
Then
Exit
Sub
Set
AppWD = CreateObject(
"Word.Application"
)
Set
wdDoc = AppWD.Documents.Open( _
Filename:=fn, _
ConfirmConversions:=
False
, _
ReadOnly
:=
False
, _
AddToRecentFiles:=
False
, _
PasswordDocument:=
""
, _
PasswordTemplate:=
""
, _
Revert:=
False
, _
WritePasswordDocument:=
""
, _
WritePasswordTemplate:=
""
, _
Format:=wdOpenFormatAuto, _
Visible:=
True
)
intCol = 1
For
intRowCnt = 1
To
Cells(Rows.Count, intCol).
End
(xlUp).Row
PersonName = Cells(intRowCnt, intCol)
<strong><em>
With
wdDoc.Selection.Find
.ClearFormatting
.Text = PersonName
.Execute Forward =
True
End
With
Cells(intRowCnt, 2) = wdDoc.Selection.Information(wdActiveEndAdjustedPageNumber)</em></strong>
Next
AppWD.Documents(fn).Close SaveChanges:=
False
AppWD.Quit
Set
AppWD =
Nothing
End
Sub