A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Crash when using GetInspector



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old January 20th 10, 08:34 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Crash when using GetInspector



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
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 04:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.