Option
Explicit
Sub
openTemplateWithTextbox()
Dim
sTemplate
As
String
Dim
Vorlage
As
Outlook.AppointmentItem
Dim
insp
As
Outlook.Inspector
Dim
wdDoc
As
Word.Document
Dim
sh
As
Word.Shape
On
Error
GoTo
FinisErr
sTemplate = "C:\Users\marco.sechi\AppData\Roaming\Microsoft\" & _
"Templates\Unbenannt.oft"
Set
Vorlage = Outlook.CreateItemFromTemplate(sTemplate)
If
Vorlage
Is
Nothing
Then
MsgBox
"Die Vorlage "
""
& sTemplate &
""
" konnte nicht geöffnet werden."
_
, vbCritical + vbOKOnly,
"Vorlage öffnen"
Exit
Sub
End
If
Vorlage.Display
Set
insp = Outlook.ActiveInspector
With
insp
Set
wdDoc = .WordEditor
With
wdDoc
If
.Shapes.Count > 0
Then
Set
sh = .Shapes(1)
With
sh
MsgBox
"Inhalt der Textbox: "
& vbNewLine & .TextFrame.TextRange.Text
.TextFrame.TextRange.Text =
"Wertzuweisung"
End
With
End
If
End
With
End
With
FinisErr:
If
err.Number <> 0
Then
MsgBox err.Number & vbNewLine & err.Description
End
If
Set
insp =
Nothing
:
Set
wdDoc =
Nothing
:
Set
sh =
Nothing
End
Sub