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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Inspector and adding a custom toolbar



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 3rd 06, 12:16 AM posted to microsoft.public.outlook.program_addins
Paul Heinisch
external usenet poster
 
Posts: 5
Default Inspector and adding a custom toolbar

I don't think I explained it correctly in my last message; I don't want to
add a button to the standard menu, I want to make that when I open a contact
(inspector class) a new toolbar opens with my new button. I have no problem
with adding one to the explorer...but when I try to add it to the inspector I
get "Object reference not set to an instance of an object.". So I know I'm
doing it wrong. Any help?
Ads
  #2  
Old September 4th 06, 06:04 AM posted to microsoft.public.outlook.program_addins
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Inspector and adding a custom toolbar

Am Sat, 2 Sep 2006 16:16:02 -0700 schrieb Paul Heinisch:

I don“t know what you "last message" is, hopefully I don“t miss anything:
use the Inspector.Commandbars (instead of Explorer.Commandbars) in the
NewInspector event.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I don't think I explained it correctly in my last message; I don't want to
add a button to the standard menu, I want to make that when I open a

contact
(inspector class) a new toolbar opens with my new button. I have no

problem
with adding one to the explorer...but when I try to add it to the

inspector I
get "Object reference not set to an instance of an object.". So I know I'm
doing it wrong. Any help?

  #3  
Old September 4th 06, 03:45 PM posted to microsoft.public.outlook.program_addins
Paul Heinisch
external usenet poster
 
Posts: 5
Default Inspector and adding a custom toolbar

I did...but I get an error message each time its run...object reference not
set to an instance of an object...

"Michael Bauer [MVP - Outlook]" wrote:

Am Sat, 2 Sep 2006 16:16:02 -0700 schrieb Paul Heinisch:

I donĀ“t know what you "last message" is, hopefully I donĀ“t miss anything:
use the Inspector.Commandbars (instead of Explorer.Commandbars) in the
NewInspector event.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I don't think I explained it correctly in my last message; I don't want to
add a button to the standard menu, I want to make that when I open a

contact
(inspector class) a new toolbar opens with my new button. I have no

problem
with adding one to the explorer...but when I try to add it to the

inspector I
get "Object reference not set to an instance of an object.". So I know I'm
doing it wrong. Any help?


  #4  
Old September 5th 06, 05:25 AM posted to microsoft.public.outlook.program_addins
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Inspector and adding a custom toolbar

Am Mon, 4 Sep 2006 07:45:02 -0700 schrieb Paul Heinisch:

Please show your code.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I did...but I get an error message each time its run...object reference

not
set to an instance of an object...

"Michael Bauer [MVP - Outlook]" wrote:

Am Sat, 2 Sep 2006 16:16:02 -0700 schrieb Paul Heinisch:

I don“t know what you "last message" is, hopefully I don“t miss anything:
use the Inspector.Commandbars (instead of Explorer.Commandbars) in the
NewInspector event.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I don't think I explained it correctly in my last message; I don't want

to
add a button to the standard menu, I want to make that when I open a

contact
(inspector class) a new toolbar opens with my new button. I have no

problem
with adding one to the explorer...but when I try to add it to the

inspector I
get "Object reference not set to an instance of an object.". So I know

I'm
doing it wrong. Any help?


  #5  
Old September 5th 06, 06:01 AM posted to microsoft.public.outlook.program_addins
Paul Heinisch
external usenet poster
 
Posts: 5
Default Inspector and adding a custom toolbar

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim oApp As outlook.Application
Dim addInInstance As Microsoft.Office.Core.COMAddIn
Dim newToolBar As office.CommandBar
Dim WithEvents firstButton As office.CommandBarButton

Dim WithEvents selectInspector As outlook.Inspectors


Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

selectInspector = oApp.Inspectors
AddHandler selectInspector.NewInspector, AddressOf
Me.NewInspector_Event

End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
oApp = CType(application,
Microsoft.Office.Interop.Outlook.Application)
addInInstance = CType(addInInst, Microsoft.Office.Core.COMAddIn)

End Sub

Private Sub NewInspector_Event(ByVal new_Inspector As outlook.Inspector)

new_Inspector.Activate()
newToolBar = Nothing
Call Me.AddToolbar()


End Sub

Private Sub AddToolbar()
Try

Dim button_1 As office.CommandBarButton

If newToolBar Is Nothing Then
Dim cmdBars As office.CommandBars =
oApp.ActiveInspector().CommandBars
newToolBar = cmdBars.Add("NewToolBar",
office.MsoBarPosition.msoBarTop, False, True)
End If
Try
button_1 = CType(newToolBar.Controls.Add(1),
office.CommandBarButton)
With button_1
.Style = office.MsoButtonStyle.msoButtonCaption
.Caption = "Button 1"
.Tag = "Button1"
End With
If Me.firstButton Is Nothing Then
Me.firstButton = button_1
AddHandler firstButton.Click, AddressOf buttonClick
End If

newToolBar.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
Catch ex As Exception
MsgBox(ex.Message)
MsgBox(ex.StackTrace)
End Try
End Sub



Private Sub buttonClick(ByVal ctrl As office.CommandBarButton, ByRef
Cancel As Boolean)
MsgBox("You clicked: " + ctrl.Caption)
End Sub




End Class

"Michael Bauer [MVP - Outlook]" wrote:

Am Mon, 4 Sep 2006 07:45:02 -0700 schrieb Paul Heinisch:

Please show your code.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I did...but I get an error message each time its run...object reference

not
set to an instance of an object...

"Michael Bauer [MVP - Outlook]" wrote:

Am Sat, 2 Sep 2006 16:16:02 -0700 schrieb Paul Heinisch:

I donĀ“t know what you "last message" is, hopefully I donĀ“t miss anything:
use the Inspector.Commandbars (instead of Explorer.Commandbars) in the
NewInspector event.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I don't think I explained it correctly in my last message; I don't want

to
add a button to the standard menu, I want to make that when I open a
contact
(inspector class) a new toolbar opens with my new button. I have no
problem
with adding one to the explorer...but when I try to add it to the
inspector I
get "Object reference not set to an instance of an object.". So I know

I'm
doing it wrong. Any help?


  #6  
Old September 5th 06, 02:49 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Inspector and adding a custom toolbar

Don't try to activate the Inspector in the NewInspector event handler.
Handle the Inspector events and in the Activate event create your toolbar.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Paul Heinisch" wrote in message
...
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim oApp As outlook.Application
Dim addInInstance As Microsoft.Office.Core.COMAddIn
Dim newToolBar As office.CommandBar
Dim WithEvents firstButton As office.CommandBarButton

Dim WithEvents selectInspector As outlook.Inspectors


Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

selectInspector = oApp.Inspectors
AddHandler selectInspector.NewInspector, AddressOf
Me.NewInspector_Event

End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom
As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
oApp = CType(application,
Microsoft.Office.Interop.Outlook.Application)
addInInstance = CType(addInInst, Microsoft.Office.Core.COMAddIn)

End Sub

Private Sub NewInspector_Event(ByVal new_Inspector As
outlook.Inspector)

new_Inspector.Activate()
newToolBar = Nothing
Call Me.AddToolbar()


End Sub

Private Sub AddToolbar()
Try

Dim button_1 As office.CommandBarButton

If newToolBar Is Nothing Then
Dim cmdBars As office.CommandBars =
oApp.ActiveInspector().CommandBars
newToolBar = cmdBars.Add("NewToolBar",
office.MsoBarPosition.msoBarTop, False, True)
End If
Try
button_1 = CType(newToolBar.Controls.Add(1),
office.CommandBarButton)
With button_1
.Style = office.MsoButtonStyle.msoButtonCaption
.Caption = "Button 1"
.Tag = "Button1"
End With
If Me.firstButton Is Nothing Then
Me.firstButton = button_1
AddHandler firstButton.Click, AddressOf buttonClick
End If

newToolBar.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
Catch ex As Exception
MsgBox(ex.Message)
MsgBox(ex.StackTrace)
End Try
End Sub



Private Sub buttonClick(ByVal ctrl As office.CommandBarButton, ByRef
Cancel As Boolean)
MsgBox("You clicked: " + ctrl.Caption)
End Sub




End Class


  #7  
Old September 5th 06, 05:14 PM posted to microsoft.public.outlook.program_addins
Paul Heinisch
external usenet poster
 
Posts: 5
Default Inspector and adding a custom toolbar

I did that...but I'm still getting an error message bject reference not set
to an instance of an object....on this line:

Dim cmdBars As office.CommandBars = oApp.ActiveInspector().CommandBars

What am I doing wrong? Thanks for your help!

Paul

"Ken Slovak - [MVP - Outlook]" wrote:

Don't try to activate the Inspector in the NewInspector event handler.
Handle the Inspector events and in the Activate event create your toolbar.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Paul Heinisch" wrote in message
...
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim oApp As outlook.Application
Dim addInInstance As Microsoft.Office.Core.COMAddIn
Dim newToolBar As office.CommandBar
Dim WithEvents firstButton As office.CommandBarButton

Dim WithEvents selectInspector As outlook.Inspectors


Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

selectInspector = oApp.Inspectors
AddHandler selectInspector.NewInspector, AddressOf
Me.NewInspector_Event

End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
End Sub

Public Sub OnConnection(ByVal application As Object, ByVal connectMode
As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom
As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
oApp = CType(application,
Microsoft.Office.Interop.Outlook.Application)
addInInstance = CType(addInInst, Microsoft.Office.Core.COMAddIn)

End Sub

Private Sub NewInspector_Event(ByVal new_Inspector As
outlook.Inspector)

new_Inspector.Activate()
newToolBar = Nothing
Call Me.AddToolbar()


End Sub

Private Sub AddToolbar()
Try

Dim button_1 As office.CommandBarButton

If newToolBar Is Nothing Then
Dim cmdBars As office.CommandBars =
oApp.ActiveInspector().CommandBars
newToolBar = cmdBars.Add("NewToolBar",
office.MsoBarPosition.msoBarTop, False, True)
End If
Try
button_1 = CType(newToolBar.Controls.Add(1),
office.CommandBarButton)
With button_1
.Style = office.MsoButtonStyle.msoButtonCaption
.Caption = "Button 1"
.Tag = "Button1"
End With
If Me.firstButton Is Nothing Then
Me.firstButton = button_1
AddHandler firstButton.Click, AddressOf buttonClick
End If

newToolBar.Visible = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
Catch ex As Exception
MsgBox(ex.Message)
MsgBox(ex.StackTrace)
End Try
End Sub



Private Sub buttonClick(ByVal ctrl As office.CommandBarButton, ByRef
Cancel As Boolean)
MsgBox("You clicked: " + ctrl.Caption)
End Sub




End Class



  #8  
Old September 5th 06, 06:00 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Inspector and adding a custom toolbar

That's something to find out in the debugger. Is oApp valid at that point?
Is there an ActiveInspector object? It's hard to debug when multiple dot
operators are used, any break in the chain of instantiated items can cause
that error.

Are you keeping alive references to things you add that must be global or
module level? Unexpected garbage collection is a very common problem with
..NET code, things get collected and no longer are valid object references.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Paul Heinisch" wrote in message
...
I did that...but I'm still getting an error message bject reference not
set
to an instance of an object....on this line:

Dim cmdBars As office.CommandBars = oApp.ActiveInspector().CommandBars

What am I doing wrong? Thanks for your help!

Paul


 




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
re-post: custom button in custom toolbar stef Outlook - General Queries 3 August 8th 06 10:30 PM
re-post: custom button in custom toolbar stef Outlook and VBA 3 August 8th 06 10:30 PM
custom button in custom toolbar stef Outlook - General Queries 0 August 5th 06 07:57 PM
adding coomand bar buttons to inspector window Ram Add-ins for Outlook 4 May 26th 06 06:16 AM
add toolbar in inspector contact item Irene Outlook and VBA 1 February 24th 06 09:23 PM


All times are GMT +1. The time now is 06:02 PM.


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