Outlook-Menüleiste per VBA funktioniert nicht
Hallo,
ich würde mir gerne eine eigene Menüleiste mit Combo-Box in Outlook 2003 programmieren, dazu gibt es auch eine Hilfeseite bei Microsoft:
http://www.microsoft.com/germany/msdn/library/office/MehrZumThemaProgra ...
Wenn ich nachstehendes Script (minimale Veränderungen aus der MS-Seite) ausführe, da bleibt es mir an dieser Zeile mit Laufzeitfehler 438 (Objekt unterstützt diese Eigenschaft oder Methode nicht) hängen. Und das bei OL2003 und OL2000:
' Die nächste Codezeile ersetzen durch:
Set objCommandBarComboBox = _
Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox)
'<- Für Outlook ÄNDERUNG: HIER AKTIVIERT
An was könnte das liegen?
Danke für jede Hilfe
Mark
Public Function AddComboBoxToCommandBar(ByVal strCommandBarName As String, _
ByVal strComboBoxCaption As String, _
ByRef strChoices() As String) As Boolean
' Zweck: Fügt einer Befehlsleiste ein Kombinationsfeld hinzu.
' Akzeptiert:
' strCommandBarName: Der Name der Befehlsleiste zum Hinzufügen des Kombinationsfeldes.
' strChoices(): Ein Optionsarray für das Kombinationsfeld.
' Rückgabe: TRUE, wenn das Kombinationsfeld erfolgreich der Befehlsleiste hinzugefügt wurde.
Dim objCommandBarControl As Office.CommandBarControl
Dim objCommandBarComboBox As Office.CommandBarComboBox
Dim varChoice As Variant
'On Error GoTo AddComboBoxToCommandBar_Err ÄNDERUNG: ALS KOMMENTAR, DAMIT FEHLERMELDUNG ERSCHEINT
' Alle zuvor hinzugefügten Instanzen dieses Kombinationsfeldes löschen.
' Die nächste Codezeile ersetzen durch:
For Each objCommandBarControl In _
Application.ActiveExplorer.CommandBars.Item(strCommandBarName).Controls
'<- Für Outlook ÄNDERUNG: HIER AKTIVIERT
' For Each objCommandBarControl In _
' Application.VBE.CommandBars.Item(strCommandBarName).Controls _
<- Für Visual Basic-Editor
'For Each objCommandBarControl In Application.CommandBars.Item(strCommandBarName).Controls
If objCommandBarControl.Caption = strComboBoxCaption Then
objCommandBarControl.Delete
End If
Next objCommandBarControl
' Das Kombinationsfeld erstellen.
' Die nächste Codezeile ersetzen durch:
Set objCommandBarComboBox = _
Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox)
'<- Für Outlook ÄNDERUNG: HIER AKTIVIERT
' Set objCommandBarComboBox = _
' Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox) _
<- Für Visual Basic-Editor
'Set objCommandBarComboBox = _
Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox)
objCommandBarComboBox.Caption = strComboBoxCaption
For Each varChoice In strChoices
objCommandBarComboBox.AddItem varChoice
Next varChoice
AddComboBoxToCommandBar_End:
AddComboBoxToCommandBar = True
Exit Function
AddComboBoxToCommandBar_Err:
AddComboBoxToCommandBar = False
End Function
Public Sub TestAddComboBoxToCommandBar()
' Zweck: Testet die AddComboBoxToCommandBar-Funktion.
Dim strChoices(4) As String
strChoices(1) = "Vanilla"
strChoices(2) = "Chocolate"
strChoices(3) = "Strawberry"
strChoices(4) = "Other"
If AddComboBoxToCommandBar("Tools", "Favorite Ice Cream", _
strChoices) = True Then
MsgBox "Das Kombinationsfeld wurde erfolgreich hinzugefügt."
Else
MsgBox "Das Kombinationsfeld konnte nicht hinzugefügt werden."
End If
End Sub
ich würde mir gerne eine eigene Menüleiste mit Combo-Box in Outlook 2003 programmieren, dazu gibt es auch eine Hilfeseite bei Microsoft:
http://www.microsoft.com/germany/msdn/library/office/MehrZumThemaProgra ...
Wenn ich nachstehendes Script (minimale Veränderungen aus der MS-Seite) ausführe, da bleibt es mir an dieser Zeile mit Laufzeitfehler 438 (Objekt unterstützt diese Eigenschaft oder Methode nicht) hängen. Und das bei OL2003 und OL2000:
' Die nächste Codezeile ersetzen durch:
Set objCommandBarComboBox = _
Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox)
'<- Für Outlook ÄNDERUNG: HIER AKTIVIERT
An was könnte das liegen?
Danke für jede Hilfe
Mark
Public Function AddComboBoxToCommandBar(ByVal strCommandBarName As String, _
ByVal strComboBoxCaption As String, _
ByRef strChoices() As String) As Boolean
' Zweck: Fügt einer Befehlsleiste ein Kombinationsfeld hinzu.
' Akzeptiert:
' strCommandBarName: Der Name der Befehlsleiste zum Hinzufügen des Kombinationsfeldes.
' strChoices(): Ein Optionsarray für das Kombinationsfeld.
' Rückgabe: TRUE, wenn das Kombinationsfeld erfolgreich der Befehlsleiste hinzugefügt wurde.
Dim objCommandBarControl As Office.CommandBarControl
Dim objCommandBarComboBox As Office.CommandBarComboBox
Dim varChoice As Variant
'On Error GoTo AddComboBoxToCommandBar_Err ÄNDERUNG: ALS KOMMENTAR, DAMIT FEHLERMELDUNG ERSCHEINT
' Alle zuvor hinzugefügten Instanzen dieses Kombinationsfeldes löschen.
' Die nächste Codezeile ersetzen durch:
For Each objCommandBarControl In _
Application.ActiveExplorer.CommandBars.Item(strCommandBarName).Controls
'<- Für Outlook ÄNDERUNG: HIER AKTIVIERT
' For Each objCommandBarControl In _
' Application.VBE.CommandBars.Item(strCommandBarName).Controls _
<- Für Visual Basic-Editor
'For Each objCommandBarControl In Application.CommandBars.Item(strCommandBarName).Controls
If objCommandBarControl.Caption = strComboBoxCaption Then
objCommandBarControl.Delete
End If
Next objCommandBarControl
' Das Kombinationsfeld erstellen.
' Die nächste Codezeile ersetzen durch:
Set objCommandBarComboBox = _
Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox)
'<- Für Outlook ÄNDERUNG: HIER AKTIVIERT
' Set objCommandBarComboBox = _
' Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox) _
<- Für Visual Basic-Editor
'Set objCommandBarComboBox = _
Application.CommandBars.Item(strCommandBarName).Controls.Add(msoControlComboBox)
objCommandBarComboBox.Caption = strComboBoxCaption
For Each varChoice In strChoices
objCommandBarComboBox.AddItem varChoice
Next varChoice
AddComboBoxToCommandBar_End:
AddComboBoxToCommandBar = True
Exit Function
AddComboBoxToCommandBar_Err:
AddComboBoxToCommandBar = False
End Function
Public Sub TestAddComboBoxToCommandBar()
' Zweck: Testet die AddComboBoxToCommandBar-Funktion.
Dim strChoices(4) As String
strChoices(1) = "Vanilla"
strChoices(2) = "Chocolate"
strChoices(3) = "Strawberry"
strChoices(4) = "Other"
If AddComboBoxToCommandBar("Tools", "Favorite Ice Cream", _
strChoices) = True Then
MsgBox "Das Kombinationsfeld wurde erfolgreich hinzugefügt."
Else
MsgBox "Das Kombinationsfeld konnte nicht hinzugefügt werden."
End If
End Sub
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 82187
Url: https://administrator.de/forum/outlook-menueleiste-per-vba-funktioniert-nicht-82187.html
Ausgedruckt am: 01.05.2025 um 15:05 Uhr
1 Kommentar