![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]() If the purpose is only to create the commandbar, use the NewInspector event. And if the code runs within Outlook, don't call GetObject or CreateObject, instead use the instrinsic Application object. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Tue, 19 Jan 2010 21:44:59 +0000 schrieb technomane: 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook Crash | KeithMeister | Outlook - Installation | 6 | January 29th 09 03:01 PM |
HD crash - only have .dbx files | Soren | Outlook - General Queries | 3 | June 28th 06 02:27 PM |
my ie6 crash | registerer seeking help | Outlook Express | 1 | May 22nd 06 01:16 AM |
pc crash | Trevor | Outlook - Installation | 2 | April 16th 06 09:34 AM |
Help I had a crash | gary | Outlook Express | 5 | February 8th 06 01:36 PM |