PC Review


Reply
Thread Tools Rate Thread

Crash when using GetInspector

 
 
technomane
Guest
Posts: n/a
 
      19th Jan 2010

Hello all,
hope you can help me with my problem here. The following code crashe
at line "Set myInspector = myItemb.GetInspector" (Outlook completel
crashes and needs to restart). I have no idea why this happens. Fro
what I've tried, it only crashes when the macro is started right afte
OL startup, while no inspector item was yet launched. When I click o
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 t
every new inspector item (like you would do via "customize" -> "comman
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 Su


--
technomane
 
Reply With Quote
 
 
 
 
Michael Bauer [MVP - Outlook]
Guest
Posts: n/a
 
      20th Jan 2010


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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spider sol. causing crash/verifier.exe causes stop error d6 crash =?Utf-8?B?UmVkbGluZWQwMUc=?= Windows XP Configuration 0 5th May 2006 10:04 AM
Re: How to disable mailitem.GetInspector pop-up error? Sue Mosher [MVP-Outlook] Microsoft Outlook VBA Programming 7 23rd Jan 2005 03:36 AM
Picture Video - crash,crash,crash =?Utf-8?B?TUNH?= Windows XP MovieMaker 3 23rd Sep 2004 05:39 PM
Operation Failed with GetInspector.ModifiedFormPages(".....").To.Text = "" JimmyW Microsoft Outlook Form Programming 1 30th Oct 2003 04:25 PM
Re: Object not found using Item.GetInspector when item is not read Pierre Microsoft Outlook Form Programming 0 15th Jul 2003 10:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:56 PM.