Dank der Hilfe eines Kollegen konnte das Problem mit "„Private Sub Application_Itemsend….." gelöst werden.
Wenn ich auf den Button "Senden" klicke. Wird das Testskript nun ausgeführt.
Das Testskript hatte aber lediglich die Aufgabe die Betreffzeile zu ändern. Wie gesagt taste mich an die Lösung ran.
Habe aber unter "http://www.hilpers.com/860800-per-vba-das-feld-einfuegen" ein Skript gefunden, welches eher meinen Anforderungen entspricht (Quelltext siehe unten).
Dim Variable1 As String, Signature As String, LineBuffer As String
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim ans
ans = MsgBox("Signatur hinzufügen??", vbYesNo)
If ans = vbNo Then Exit Sub
If ans = vbYes Then
Call SetSignature(SignaturName)
End If
End Sub
Sub SetSignature(ByVal SignatureName As String)
Const ID_INSERT As Integer = 30005
Const ID_SIGNATURES As Integer = 31145
Dim objInspector As Outlook.Inspector
Dim objCommandBars As Office.CommandBars
Dim objCommandBarPopup As Office.CommandBarPopup
Dim objCommandBarControl As CommandBarButton
Dim objCommandBarControls As CommandBarPopup
Dim strButtonName As String
Set objInspector = Outlook.ActiveInspector
If Not objInspector Is Nothing Then
If objInspector.IsWordMail = True Then GoTo ExitProc
Set objCommandBars = objInspector.CommandBars
Set objCommandBarPopup = objCommandBars.FindControl(,
ID_INSERT)
If Not objCommandBarPopup Is Nothing Then
Set objCommandBarControls = objCommandBars.FindControl(,
ID_SIGNATURES)
If Not objCommandBarControls Is Nothing Then
For Each objCommandBarControl In
objCommandBarControls.Controls
strButtonName = objCommandBarControl.Caption
If strButtonName = SignatureName Then
objCommandBarControl.Execute
GoTo ExitProc
End If
Next
objCommandBarPopup.Controls(1).Execute
End If
End If
End If
ExitProc:
Set objCommandBarControl = Nothing
Set objCommandBarPopup = Nothing
Set objCommandBars = Nothing
Set objInspector = Nothing
End Sub
Leider scheint das Skript unter Outlook 2007 nicht zu funktionieren.
Muss aber auch zugeben, dass ich nicht jede Zeile verstehe.
Kennt jemand von euch zufällig Quellen wo man die Syntax von VBA unter Outlook nachschlagen könnte?
Ist ein wenig schwierig ohne genaue Kenntnisse über die Syntax bzw. Objekte wie z.B. Outlook.ActiveInspector eine Lösung zu erarbeiten.....