Sub
TextmarkenAnsteuern()
Dim
appWord
As
Object
Dim
wrdDocument as
Object
On
Error
Resume
Next
Set
appWord = GetObject(,
"Word.Application"
)
If
Err = 429
Then
Err.Clear
Set
appWord = CreateObject(
"Word.Application"
)
If
Err > 0
Then
MsgBox
"Fehler beim Starten von Word!"
Exit
Sub
End
If
End
If
Err.Clear
Set
wrdDocument = appWord.Documents.Open(
"C:\Testen\Test.doc"
)
If
Err = 1004
Then
MsgBox
"Dokument 'Test.doc' nicht vorhanden!"
appWord.Quit
Set
appWord =
Nothing
Exit
Sub
End
If
On
Error
Goto 0
appWord.Visible =
True
wrdDocument.Bookmarks(
"Textmarke1"
).
Select
appWord.Selection.MoveLeft , ,
True
appWord.Selection.TypeText
"Mustertext Eins"
wrdDocument.Bookmarks(
"Textmarke2"
).
Select
appWord.Selection.MoveLeft , ,
True
appWord.Selection.TypeText
"Mustertext Zwei"
End
Sub