Crash when using GetInspector

  • Thread starter Thread starter technomane
  • Start date Start date
Status
Not open for further replies.
T

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

technomane
 
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

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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T issue bcm crash when using mousewheel BCM (Business Contact Manager) 7
J Outlook, Word, Access crash unless run in Admin mode - time dependent it seems Using Outlook 12
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 10
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
GregS Immediate crash on opening Using Outlook 3
H How-To recover email from Computer Crash Using Outlook 2
E I have had a total server crash. Exchange Server Administration 2
S BCM crash Atheros Addin 2010 Using Outlook 1
H Scroll Crash BCM (Business Contact Manager) 2
B Trouble Starting Outlook 2010 after Crash Using Outlook 3
K Outlook Crash on referencing forms Using Outlook 1
jobudge Reinstalled Outlook 2013 after system crash what is best way to synch with gmail? Using Outlook 1
B Office 2013: Crash when the E-Mails are sent Using Outlook 3
C crash during account setup - can't delete corrupted account/data file Using Outlook 13
A Major Server Crash - Now Public Calendar Categories Aren't Working! Using Outlook 1
T New Inspector word editor crash Outlook 2003 Outlook VBA and Custom Forms 3
S Business Contact Manager (BCM) causing Outlook crash loop BCM (Business Contact Manager) 3
J BCM -07 Restoration - File Crash BCM (Business Contact Manager) 2
L How do you Recover from An Outlook 2007 & BCM Crash BCM (Business Contact Manager) 1
A COM add-in causes Outlook 2007 to periodically crash where it did not in Outlook 2003 Outlook VBA and Custom Forms 3
R How do I reconnect the database files after a system crash? BCM (Business Contact Manager) 11
D Send email from Outlook Alias using Mac? Using Outlook 0
H using VBA to edit subject line Outlook VBA and Custom Forms 0
e_a_g_l_e_p_i Need clarification on 2-Step Verification for Gmail using Outlook 2021 Using Outlook 10
e_a_g_l_e_p_i Outlook 2021 not letting me setup my Gmail using pop Using Outlook 1
O How to find out the domain and server settings that my Outlook is using? Using Outlook 2
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
R Advise on using multiple instances of network files based on customers Outlook VBA and Custom Forms 8
HarvMan Using Emojis in Outlook 365 Using Outlook 3
T Outlook 2019 Not Using Auto Compete After Deletion of 365 Using Outlook 1
M USING INITIALS AS RECIPIENTS Using Outlook 1
T Outlook 2019 Using Gmail aliases in Outlook Using Outlook 6
M Saving emails using Visual Basic - Selecting folder with msoFileDialogFolderPicker Outlook VBA and Custom Forms 6
Z Import Tasks from Access Using VBA including User Defined Fields Outlook VBA and Custom Forms 0
justicefriends How to set a flag to follow up using VBA - for addressee in TO field Outlook VBA and Custom Forms 11
M Extract "Date sent" from emails (saved to folder using drag and drop) Outlook VBA and Custom Forms 1
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
H Stationery using between OL 2019 and OL 2010 Using Outlook 0
P Prevent Outlook 2016 from using DASL filter Using Outlook 4
O Calendar - Location: what happens when using my own way of entering locations Using Outlook 1
M Disable Contact Card Results when using "Search People" in Outlook Ribbon Using Outlook 7
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
pcunite Outlook 2019/O365 Build 13127.20408 errors when using MAPI calls Using Outlook 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
X Using Outlook 2013 and Outlook 365 Using Outlook 1

Similar threads

Back
Top