View Single Post
  #1  
Old January 19th 10, 09:44 PM
technomane technomane is offline
Junior Member
 
First recorded activity at Outlookbanter: Jan 2010
Posts: 1
Question Crash when using GetInspector

Hello all,
hope you can help me with my problem here. The following code crashes at line "Set myInspector = myItemb.GetInspector" (Outlook completely crashes and needs to restart). I have no idea why this happens. From what I've tried, it only crashes when the macro is started right after OL startup, while no inspector item was yet launched. When I click on e.g. "New E-Mail" first (open/close the inspector), it will not crash.

Purpose of the whole thing is to add a user-defined command bar to every new inspector item (like you would do via "customize" - "command bars" - "macros" menu)

Any help is highly appreciated

Sub DisplayFollowUpBarMenus()
Dim myOlApp As Outlook.Application
Dim myItemb As Outlook.MailItem
Dim myInspector As Outlook.Inspector
Dim cmb As CommandBar
Dim insp As Inspector

Set myOlApp = Nothing
Set myItemb = Nothing
Set myInspector = Nothing
Set myOlApp = CreateObject("Outlook.Application")
Set myItemb = myOlApp.CreateItem(olMailItem)
Set myInspector = myItemb.GetInspector

For Each cmb In myInspector.CommandBars
If cmb.Name = "Followup" Then cmb.Delete
Next
Set cb = myInspector.CommandBars.Add(Name:=Followup, _
temporary:=False, Position:=msoBarTop)
cb.Visible = True
Set cbc = cb.Controls.Add(Type:=msoControlButton)
With cbc
.FaceId = 273
.Caption = "morgen"
.Style = msoButtonIconAndCaption
.OnAction = "FUtomorrow"
End With
Set cbc = cb.Controls.Add(Type:=msoControlButton)
With cbc
.FaceId = 273
.Caption = "5"
.OnAction = "FUfivedays"
.Style = msoButtonIconAndCaption
.BeginGroup = True
End With

myInspector.Display
myInspector.Close (olDiscard)
End Sub
Ads