Launching VB forms from Outlook

  • Thread starter Thread starter Sarah S
  • Start date Start date
S

Sarah S

This is my first attemt w/ Outlook and I am using the
provided sample and the book "Microsoft Outlook
Programming. I have been using the sample project ItemsCB
as a base for creating my application. I added a command
bar button to the MailItem Standard toolbar using this
code:

Set cb = Inspector.CommandBars.Item("Standard")

When that button is clicked, I want to launch a VB 6 form
I designed. I created my Inspector wrapper class
following the ExplWrap class. I instantiate my inspector
object as follows and use WithEvents:

Public Property Let Inspector(objInsp As Outlook.Inspector)
On Error Resume Next
Set m_objInsp = objInsp
Set m_MailItem = objInsp.CurrentItem
Set m_colInsps = Outlook.Inspectors
End Property

When a m_colInsps_NewInspector is fired, I see if I need
to add my button. Things seem to go well up to this
point, but when I click on my button to launch my own
form, I get an error when I try and show the form
using .Show vbModal, Me.

I get error 371 which is:

The specified object can't be used as an owner form for
Show() (Error 371)

You must use an appropriate object with the Show method.

Can I not use my own VB form? Do I have to make it am
Outlook Custom Designed form?
 
That did work. I'm so used to using vbModal, Me that I
didn't even thing of taking the Me off.

I'm having another slight problem w/ my app. All the
events are firing twice. I just expanded on ItemsCB by
adding my Inspector wrapper class modeling after the
sample Explorer. I tried to put in some logic to not fire
them twice, but was unsuccessful. I will continue to
debug, but any idea as to this?

Thanks.
 
Make sure that each button you add has a unique Tag property. Otherwise you
will get a Click event firing in every wrapper class where you have
instantiated the button. I usually use a fixed button Tag string and append
to that the unique Key value that each Inspector wrapper class is assigned
when it's added to the wrapper collection. That guarantees a unique Tag.
 
Back
Top