Home All Groups Group Topic Archive Search About

How do I modify a value for each New Mail Message?

Author
27 Sep 2007 2:32 PM
AgapeDisciple
I have a toolbar button within the mailitem that executes a function
and changes the icon when the user clicks on it. I need to reset the
icon to the default image for each new mail message.

Currently I am doing this whenever the item is sent using
"Application_ItemSend".  But if the message does not get sent and a
new mail message is started, the toolbar will not be reset.  I've
searched the forums, but I cannot find a way to run the same commands
when the Outlook "New Mail Message" button is used.

Could somebody help?

Private Sub Application_ItemSend _
    (ByVal Item As Object, Cancel As Boolean)

   'Reset toolbar button on Send
   ResetButton

End Sub

Thanks,
Logan

Author
27 Sep 2007 3:39 PM
Ken Slovak - [MVP - Outlook]
Trap the NewInspector event of the Inspectors collection. Make sure to check
Inspector.Class in that event handler to make sure you are only handling
Inspectors of the type or types you want.

If you are accessing the CommandBars collection of the Inspector make sure
not to access it or work with it until you get the first Activate event for
the Inspector. The CommandBars collection is not guaranteed to be available
in NewInspector since you only get a weak object reference in that event for
the Inspector.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Show quote
"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1190903533.070208.138640@w3g2000hsg.googlegroups.com...
>I have a toolbar button within the mailitem that executes a function
> and changes the icon when the user clicks on it. I need to reset the
> icon to the default image for each new mail message.
>
> Currently I am doing this whenever the item is sent using
> "Application_ItemSend".  But if the message does not get sent and a
> new mail message is started, the toolbar will not be reset.  I've
> searched the forums, but I cannot find a way to run the same commands
> when the Outlook "New Mail Message" button is used.
>
> Could somebody help?
>
> Private Sub Application_ItemSend _
>    (ByVal Item As Object, Cancel As Boolean)
>
>   'Reset toolbar button on Send
>   ResetButton
>
> End Sub
>
> Thanks,
> Logan
>
Author
27 Sep 2007 5:48 PM
AgapeDisciple
On Sep 27, 11:39 am, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> Trap the NewInspector event of the Inspectors collection. Make sure to check
> Inspector.Class in that event handler to make sure you are only handling
> Inspectors of the type or types you want.
>
> If you are accessing the CommandBars collection of the Inspector make sure
> not to access it or work with it until you get the first Activate event for
> the Inspector. The CommandBars collection is not guaranteed to be available
> in NewInspector since you only get a weak object reference in that event for
> the Inspector.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1190903533.070208.138640@w3g2000hsg.googlegroups.com...
>
>
>
> >I have a toolbar button within the mailitem that executes a function
> > and changes the icon when the user clicks on it. I need to reset the
> > icon to the default image for each new mail message.
>
> > Currently I am doing this whenever the item is sent using
> > "Application_ItemSend".  But if the message does not get sent and a
> > new mail message is started, the toolbar will not be reset.  I've
> > searched the forums, but I cannot find a way to run the same commands
> > when the Outlook "New Mail Message" button is used.
>
> > Could somebody help?
>
> > Private Sub Application_ItemSend _
> >    (ByVal Item As Object, Cancel As Boolean)
>
> >   'Reset toolbar button on Send
> >   ResetButton
>
> > End Sub
>
> > Thanks,
> > Logan- Hide quoted text -
>
> - Show quoted text -

Thanks for the info. I implemented the NewInspector, but I'm missing
something.  Can you help me out?

Public WithEvents InitToolInspectors As Outlook.Inspectors
Private Sub Application_Startup()
    Call Initialize_handler
End Sub
Public Sub Initialize_handler()
    Set InitToolInspectors = Application.Inspectors
End Sub
Private Sub InitToolInspectors_NewInspector _
    (ByVal Inspector As Outlook.Inspector)
    'Reset toolbar button on starting New Message
    ResetButton
End Sub

Thanks
Author
27 Sep 2007 6:14 PM
Ken Slovak - [MVP - Outlook]
You should test for Inspector.Class = olMail if you only want to handle mail
items. Then you should have an Inspector declared WithEvents so you can
handle its events. If you want to handle more than one Inspector you will
need wrapper classes and a collection to hold the wrapper classes.

Your Inspector object declared WithEvents can then handle the Activate event
and on the first firing of that event you can call your button procedure,
don't do it in NewInspector as I said before.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1190915281.935559.247570@y42g2000hsy.googlegroups.com...
<snip>
Show quote
> Thanks for the info. I implemented the NewInspector, but I'm missing
> something.  Can you help me out?
>
> Public WithEvents InitToolInspectors As Outlook.Inspectors
> Private Sub Application_Startup()
>    Call Initialize_handler
> End Sub
> Public Sub Initialize_handler()
>    Set InitToolInspectors = Application.Inspectors
> End Sub
> Private Sub InitToolInspectors_NewInspector _
>    (ByVal Inspector As Outlook.Inspector)
>    'Reset toolbar button on starting New Message
>    ResetButton
> End Sub
>
> Thanks
>
Author
27 Sep 2007 6:40 PM
AgapeDisciple
On Sep 27, 2:14 pm, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> You should test for Inspector.Class = olMail if you only want to handle mail
> items. Then you should have an Inspector declared WithEvents so you can
> handle its events. If you want to handle more than one Inspector you will
> need wrapper classes and a collection to hold the wrapper classes.
>
> Your Inspector object declared WithEvents can then handle the Activate event
> and on the first firing of that event you can call your button procedure,
> don't do it in NewInspector as I said before.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1190915281.935559.247570@y42g2000hsy.googlegroups.com...
> <snip>
>
>
>
> > Thanks for the info. I implemented the NewInspector, but I'm missing
> > something.  Can you help me out?
>
> > Public WithEvents InitToolInspectors As Outlook.Inspectors
> > Private Sub Application_Startup()
> >    Call Initialize_handler
> > End Sub
> > Public Sub Initialize_handler()
> >    Set InitToolInspectors = Application.Inspectors
> > End Sub
> > Private Sub InitToolInspectors_NewInspector _
> >    (ByVal Inspector As Outlook.Inspector)
> >    'Reset toolbar button on starting New Message
> >    ResetButton
> > End Sub
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -

I searched the help, but I don't see an "Activate" event. I do see a
"Deactivate" event. What am I missing?

Thanks
Author
27 Sep 2007 6:57 PM
AgapeDisciple
On Sep 27, 2:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
Show quote
> On Sep 27, 2:14 pm, "Ken Slovak - [MVP - Outlook]"
>
>
>
>
>
> <kenslo***@mvps.org> wrote:
> > You should test for Inspector.Class = olMail if you only want to handle mail
> > items. Then you should have an Inspector declared WithEvents so you can
> > handle its events. If you want to handle more than one Inspector you will
> > need wrapper classes and a collection to hold the wrapper classes.
>
> > Your Inspector object declared WithEvents can then handle the Activate event
> > and on the first firing of that event you can call your button procedure,
> > don't do it in NewInspector as I said before.
>
> > --
> > Ken Slovak
> > [MVP - Outlook]http://www.slovaktech.com
> > Author: Professional Programming Outlook 2007
> > Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> > "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> >news:1190915281.935559.247570@y42g2000hsy.googlegroups.com...
> > <snip>
>
> > > Thanks for the info. I implemented the NewInspector, but I'm missing
> > > something.  Can you help me out?
>
> > > Public WithEvents InitToolInspectors As Outlook.Inspectors
> > > Private Sub Application_Startup()
> > >    Call Initialize_handler
> > > End Sub
> > > Public Sub Initialize_handler()
> > >    Set InitToolInspectors = Application.Inspectors
> > > End Sub
> > > Private Sub InitToolInspectors_NewInspector _
> > >    (ByVal Inspector As Outlook.Inspector)
> > >    'Reset toolbar button on starting New Message
> > >    ResetButton
> > > End Sub
>
> > > Thanks- Hide quoted text -
>
> > - Show quoted text -
>
> I searched the help, but I don't see an "Activate" event. I do see a
> "Deactivate" event. What am I missing?
>
> Thanks- Hide quoted text -
>
> - Show quoted text -

I tried to make my own event, but nothing happens?

Private Sub InitToolInspectors_Reset()
   MsgBox "Reseting Toolbar"
   ResetButton
End Sub
Author
27 Sep 2007 7:13 PM
Ken Slovak - [MVP - Outlook]
You can't just create your own object event that way.

I don't know what you're missing but there is an Activate event for an
Inspector object.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1190919438.429022.118190@19g2000hsx.googlegroups.com...
> On Sep 27, 2:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
<snip>
Show quote
> I tried to make my own event, but nothing happens?
>
> Private Sub InitToolInspectors_Reset()
>   MsgBox "Reseting Toolbar"
>   ResetButton
> End Sub
>
Author
27 Sep 2007 7:40 PM
AgapeDisciple
On Sep 27, 3:13 pm, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> You can't just create your own object event that way.
>
> I don't know what you're missing but there is an Activate event for an
> Inspector object.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1190919438.429022.118190@19g2000hsx.googlegroups.com...
>
>
>
> > On Sep 27, 2:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
> <snip>
> > I tried to make my own event, but nothing happens?
>
> > Private Sub InitToolInspectors_Reset()
> >   MsgBox "Reseting Toolbar"
> >   ResetButton
> > End Sub- Hide quoted text -
>
> - Show quoted text -

I'm using the NewInspector code above with this ResetButton function
that is crashing Outlook.  Any ideas?

Option Explicit
Public Sub ResetButton()

Dim oInsp As Inspector
Dim cbStandard As CommandBar

'open the appropriate inspector
Set oInsp = Application.CreateItem(olMailItem).GetInspector

Set cbStandard = oInsp.CommandBars("Standard")

'needed to commit our actions ...
oInsp.Close olDiscard

End Sub
Author
27 Sep 2007 7:54 PM
AgapeDisciple
On Sep 27, 3:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
Show quote
> On Sep 27, 3:13 pm, "Ken Slovak - [MVP - Outlook]"
>
>
>
>
>
> <kenslo***@mvps.org> wrote:
> > You can't just create your own object event that way.
>
> > I don't know what you're missing but there is an Activate event for an
> > Inspector object.
>
> > --
> > Ken Slovak
> > [MVP - Outlook]http://www.slovaktech.com
> > Author: Professional Programming Outlook 2007
> > Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> > "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> >news:1190919438.429022.118190@19g2000hsx.googlegroups.com...
>
> > > On Sep 27, 2:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
> > <snip>
> > > I tried to make my own event, but nothing happens?
>
> > > Private Sub InitToolInspectors_Reset()
> > >   MsgBox "Reseting Toolbar"
> > >   ResetButton
> > > End Sub- Hide quoted text -
>
> > - Show quoted text -
>
> I'm using the NewInspector code above with this ResetButton function
> that is crashing Outlook.  Any ideas?
>
> Option Explicit
> Public Sub ResetButton()
>
> Dim oInsp As Inspector
> Dim cbStandard As CommandBar
>
> 'open the appropriate inspector
> Set oInsp = Application.CreateItem(olMailItem).GetInspector
>
> Set cbStandard = oInsp.CommandBars("Standard")
>
> 'needed to commit our actions ...
> oInsp.Close olDiscard
>
> End Sub- Hide quoted text -
>
> - Show quoted text -

Woohoo, I fixed it by changing:

Dim oInsp As Inspector

to

Dim oInsp As Outlook.Inspector

Thanks!
Author
27 Sep 2007 8:51 PM
AgapeDisciple
On Sep 27, 3:54 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
Show quote
> On Sep 27, 3:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
>
>
>
>
>
> > On Sep 27, 3:13 pm, "Ken Slovak - [MVP - Outlook]"
>
> > <kenslo***@mvps.org> wrote:
> > > You can't just create your own object event that way.
>
> > > I don't know what you're missing but there is an Activate event for an
> > > Inspector object.
>
> > > --
> > > Ken Slovak
> > > [MVP - Outlook]http://www.slovaktech.com
> > > Author: Professional Programming Outlook 2007
> > > Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> > > "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> > >news:1190919438.429022.118190@19g2000hsx.googlegroups.com...
>
> > > > On Sep 27, 2:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
> > > <snip>
> > > > I tried to make my own event, but nothing happens?
>
> > > > Private Sub InitToolInspectors_Reset()
> > > >   MsgBox "Reseting Toolbar"
> > > >   ResetButton
> > > > End Sub- Hide quoted text -
>
> > > - Show quoted text -
>
> > I'm using the NewInspector code above with this ResetButton function
> > that is crashing Outlook.  Any ideas?
>
> > Option Explicit
> > Public Sub ResetButton()
>
> > Dim oInsp As Inspector
> > Dim cbStandard As CommandBar
>
> > 'open the appropriate inspector
> > Set oInsp = Application.CreateItem(olMailItem).GetInspector
>
> > Set cbStandard = oInsp.CommandBars("Standard")
>
> > 'needed to commit our actions ...
> > oInsp.Close olDiscard
>
> > End Sub- Hide quoted text -
>
> > - Show quoted text -
>
> Woohoo, I fixed it by changing:
>
> Dim oInsp As Inspector
>
> to
>
> Dim oInsp As Outlook.Inspector
>
> Thanks!- Hide quoted text -
>
> - Show quoted text -

I added some additional code and restarted Outlook. It's starting to
crash again. I found out that if I put a MsgBox before the FindControl
line it will not crash. Any ideas?

Option Explicit
Public Sub ResetButton()

Dim oInsp As Inspector
Dim cbStandard As CommandBar
Dim cbbTest1, cbbTest2 As CommandBarButton

'open the appropriate inspector
Set oInsp = Application.CreateItem(olMailItem).GetInspector

Set cbStandard = oInsp.CommandBars("Standard")
MsgBox "Remove me and Outlook crashes"
Set cbbTest1 = cbStandard.FindControl(, , "Button1")
Set cbbTest2 = cbStandard.FindControl(, , "Button2")

If cbbTest1 Is Nothing Then
   AddButton
End If

'needed to commit our actions ...
oInsp.Close olDiscard

End Sub
Author
27 Sep 2007 7:45 PM
AgapeDisciple
On Sep 27, 3:13 pm, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> You can't just create your own object event that way.
>
> I don't know what you're missing but there is an Activate event for an
> Inspector object.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1190919438.429022.118190@19g2000hsx.googlegroups.com...
>
>
>
> > On Sep 27, 2:40 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
> <snip>
> > I tried to make my own event, but nothing happens?
>
> > Private Sub InitToolInspectors_Reset()
> >   MsgBox "Reseting Toolbar"
> >   ResetButton
> > End Sub- Hide quoted text -
>
> - Show quoted text -

BTW, I see the "Activate" method, but I don't know how I could run it
on a new message event.
Author
28 Sep 2007 1:10 PM
Ken Slovak - [MVP - Outlook]
If you want my advice and want to avoid those crashes you really ought not
to work with the CommandBars or close the Inspector or do much of anything
with it in NewInspector. If you insist on doing that I can't help you any
more and you can expect to have lots of crashes.

Again, the place for doing what you want is the first Activate event.

You might want to look at one of the Inspector wrapper code samples at
www.outlookcode.com or if you're using VB 6 or VB.NET with Outlook 2007 you
can look at one of my project templates at
http://www.slovaktech.com/outlook_2007_templates.htm to see how to correctly
handle Inspectors and NewInspector and Inspector.Activate events.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1190922355.884617.16480@d55g2000hsg.googlegroups.com...
<snip>
Show quote
> BTW, I see the "Activate" method, but I don't know how I could run it
> on a new message event.
>
Author
1 Oct 2007 3:51 PM
AgapeDisciple
On Sep 28, 9:10 am, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> If you want my advice and want to avoid those crashes you really ought not
> to work with the CommandBars or close the Inspector or do much of anything
> with it in NewInspector. If you insist on doing that I can't help you any
> more and you can expect to have lots of crashes.
>
> Again, the place for doing what you want is the first Activate event.
>
> You might want to look at one of the Inspector wrapper code samples atwww.outlookcode.comor if you're using VB 6 or VB.NET with Outlook 2007 you
> can look at one of my project templates athttp://www.slovaktech.com/outlook_2007_templates.htmto see how to correctly
> handle Inspectors and NewInspector and Inspector.Activate events.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1190922355.884617.16480@d55g2000hsg.googlegroups.com...
> <snip>
>
>
>
> > BTW, I see the "Activate" method, but I don't know how I could run it
> > on a new message event.- Hide quoted text -
>
> - Show quoted text -

I'm fine with using the .Activate event instead of NewInspector. Do
you have any code samples for how to implement it in a similar way
with opening a new message?  I don't have Visual Studio or VB.NET, I'm
just using the 2003 built-in VBA.
Author
1 Oct 2007 3:59 PM
Ken Slovak - [MVP - Outlook]
I don't have any specific VBA examples, but you probably can find some at
www.outlookcode.com.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1191253914.808488.295890@k79g2000hse.googlegroups.com...
<snip>
Show quote
> I'm fine with using the .Activate event instead of NewInspector. Do
> you have any code samples for how to implement it in a similar way
> with opening a new message?  I don't have Visual Studio or VB.NET, I'm
> just using the 2003 built-in VBA.
>
Author
1 Oct 2007 4:28 PM
AgapeDisciple
On Oct 1, 11:59 am, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> I don't have any specific VBA examples, but you probably can find some atwww.outlookcode.com.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1191253914.808488.295890@k79g2000hse.googlegroups.com...
> <snip>
>
>
>
> > I'm fine with using the .Activate event instead of NewInspector. Do
> > you have any code samples for how to implement it in a similar way
> > with opening a new message?  I don't have Visual Studio or VB.NET, I'm
> > just using the 2003 built-in VBA.- Hide quoted text -
>
> - Show quoted text -

Thanks for getting back to me quick! I've been looking, but I couldn't
find anything that related to using the compose new email button and
"fires" the Inspector.Activate. Everything I see uses _NewInpector.
Author
1 Oct 2007 5:42 PM
Ken Slovak - [MVP - Outlook]
It doesn't matter how NewInspector is fired, once it's fired you instantiate
an Inspector object declared WithEvents and then handle the Activate event.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Show quote
"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1191256084.458399.33550@r29g2000hsg.googlegroups.com...
> On Oct 1, 11:59 am, "Ken Slovak - [MVP - Outlook]"
> <kenslo***@mvps.org> wrote:
>> I don't have any specific VBA examples, but you probably can find some
>> atwww.outlookcode.com.
>>
>> --
>> Ken Slovak
>> [MVP - Outlook]http://www.slovaktech.com
>> Author: Professional Programming Outlook 2007
>> Reminder Manager, Extended Reminders, Attachment
>> Optionshttp://www.slovaktech.com/products.htm
>>
>> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>>
>> news:1191253914.808488.295890@k79g2000hse.googlegroups.com...
>> <snip>
>>
>>
>>
>> > I'm fine with using the .Activate event instead of NewInspector. Do
>> > you have any code samples for how to implement it in a similar way
>> > with opening a new message?  I don't have Visual Studio or VB.NET, I'm
>> > just using the 2003 built-in VBA.- Hide quoted text -
>>
>> - Show quoted text -
>
> Thanks for getting back to me quick! I've been looking, but I couldn't
> find anything that related to using the compose new email button and
> "fires" the Inspector.Activate. Everything I see uses _NewInpector.
>
Author
1 Oct 2007 8:21 PM
AgapeDisciple
Show quote
On Oct 1, 1:42 pm, "Ken Slovak - [MVP - Outlook]" <kenslo***@mvps.org>
wrote:
> It doesn't matter how NewInspector is fired, once it's fired you instantiate
> an Inspector object declared WithEvents and then handle the Activate event.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1191256084.458399.33550@r29g2000hsg.googlegroups.com...
>
>
>
> > On Oct 1, 11:59 am, "Ken Slovak - [MVP - Outlook]"
> > <kenslo***@mvps.org> wrote:
> >> I don't have any specific VBA examples, but you probably can find some
> >> atwww.outlookcode.com.
>
> >> --
> >> Ken Slovak
> >> [MVP - Outlook]http://www.slovaktech.com
> >> Author: Professional Programming Outlook 2007
> >> Reminder Manager, Extended Reminders, Attachment
> >> Optionshttp://www.slovaktech.com/products.htm
>
> >> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> >>news:1191253914.808488.295890@k79g2000hse.googlegroups.com...
> >> <snip>
>
> >> > I'm fine with using the .Activate event instead of NewInspector. Do
> >> > you have any code samples for how to implement it in a similar way
> >> > with opening a new message?  I don't have Visual Studio or VB.NET, I'm
> >> > just using the 2003 built-in VBA.- Hide quoted text -
>
> >> - Show quoted text -
>
> > Thanks for getting back to me quick! I've been looking, but I couldn't
> > find anything that related to using the compose new email button and
> > "fires" the Inspector.Activate. Everything I see uses _NewInpector.- Hide quoted text -
>
> - Show quoted text -

I thought you didn't want to use the NewInspector command?
Author
2 Oct 2007 1:34 PM
Ken Slovak - [MVP - Outlook]
You have to use the NewInspector event to instantiate the new Inspector as
an Inspector object declared WithEvents. How else would you instantiate it?
You just don't do anything else in NewInspector because the weak object
reference doesn't support very much.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1191270088.483261.139750@n39g2000hsh.googlegroups.com...
<snip>
Show quote
> I thought you didn't want to use the NewInspector command?
>
Author
2 Oct 2007 4:39 PM
AgapeDisciple
Show quote
On Oct 2, 9:34 am, "Ken Slovak - [MVP - Outlook]" <kenslo***@mvps.org>
wrote:
> You have to use the NewInspector event to instantiate the new Inspector as
> an Inspector object declared WithEvents. How else would you instantiate it?
> You just don't do anything else in NewInspector because the weak object
> reference doesn't support very much.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1191270088.483261.139750@n39g2000hsh.googlegroups.com...
> <snip>
>
>
>
> > I thought you didn't want to use the NewInspector command?- Hide quoted text -
>
> - Show quoted text -

Is this what you mean? How do I get the activate event to fire on the
newInspector?

Public WithEvents InitToolInspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Call Initialize_handler
End Sub

Public Sub Initialize_handler()
    Set InitToolInspectors = Application.Inspectors
End Sub

Private Sub InitToolInspectors_NewInspector _
    (ByVal newInspector As Outlook.Inspector)
    Set newInspector = Application.ActiveInspector
End Sub

Private Sub newInspector_Activate()
    MsgBox "activate"
End Sub
Author
2 Oct 2007 6:11 PM
Ken Slovak - [MVP - Outlook]
To repeat once again:

Public WithEvents newInspector As Outlook.Inspector

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
news:1191343174.239251.79200@57g2000hsv.googlegroups.com...
<snip>
Show quote
> Is this what you mean? How do I get the activate event to fire on the
> newInspector?
>
> Public WithEvents InitToolInspectors As Outlook.Inspectors
>
> Private Sub Application_Startup()
>    Call Initialize_handler
> End Sub
>
> Public Sub Initialize_handler()
>    Set InitToolInspectors = Application.Inspectors
> End Sub
>
> Private Sub InitToolInspectors_NewInspector _
>    (ByVal newInspector As Outlook.Inspector)
>    Set newInspector = Application.ActiveInspector
> End Sub
>
> Private Sub newInspector_Activate()
>    MsgBox "activate"
> End Sub
>
Author
2 Oct 2007 6:51 PM
AgapeDisciple
Show quote
On Oct 2, 2:11 pm, "Ken Slovak - [MVP - Outlook]" <kenslo***@mvps.org>
wrote:
> To repeat once again:
>
> Public WithEvents newInspector As Outlook.Inspector
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1191343174.239251.79200@57g2000hsv.googlegroups.com...
> <snip>
>
>
>
> > Is this what you mean? How do I get the activate event to fire on the
> > newInspector?
>
> > Public WithEvents InitToolInspectors As Outlook.Inspectors
>
> > Private Sub Application_Startup()
> >    Call Initialize_handler
> > End Sub
>
> > Public Sub Initialize_handler()
> >    Set InitToolInspectors = Application.Inspectors
> > End Sub
>
> > Private Sub InitToolInspectors_NewInspector _
> >    (ByVal newInspector As Outlook.Inspector)
> >    Set newInspector = Application.ActiveInspector
> > End Sub
>
> > Private Sub newInspector_Activate()
> >    MsgBox "activate"
> > End Sub- Hide quoted text -
>
> - Show quoted text -

Thanks for the reply, but it's still not firing.  Any idea what I'm
missing now?
Author
2 Oct 2007 10:16 PM
AgapeDisciple
On Oct 2, 2:51 pm, AgapeDisciple <AgapeDisci***@gmail.com> wrote:
Show quote
> On Oct 2, 2:11 pm, "Ken Slovak - [MVP - Outlook]" <kenslo***@mvps.org>
> wrote:
>
>
>
>
>
> > To repeat once again:
>
> > Public WithEvents newInspector As Outlook.Inspector
>
> > --
> > Ken Slovak
> > [MVP - Outlook]http://www.slovaktech.com
> > Author: Professional Programming Outlook 2007
> > Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> > "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> >news:1191343174.239251.79200@57g2000hsv.googlegroups.com...
> > <snip>
>
> > > Is this what you mean? How do I get the activate event to fire on the
> > > newInspector?
>
> > > Public WithEvents InitToolInspectors As Outlook.Inspectors
>
> > > Private Sub Application_Startup()
> > >    Call Initialize_handler
> > > End Sub
>
> > > Public Sub Initialize_handler()
> > >    Set InitToolInspectors = Application.Inspectors
> > > End Sub
>
> > > Private Sub InitToolInspectors_NewInspector _
> > >    (ByVal newInspector As Outlook.Inspector)
> > >    Set newInspector = Application.ActiveInspector
> > > End Sub
>
> > > Private Sub newInspector_Activate()
> > >    MsgBox "activate"
> > > End Sub- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks for the reply, but it's still not firing.  Any idea what I'm
> missing now?- Hide quoted text -
>
> - Show quoted text -

Ok, now it's working!  Thanks for the help!
Hopefully this will permanently keep OL from crashing.

-------------------------------------------------------------------------------------
Public WithEvents InitToolInspectors As Outlook.Inspectors
Public WithEvents newInspector As Outlook.Inspector

Private Sub Application_Startup()
    Call Initialize_handler
End Sub

Public Sub Initialize_handler()
    Set InitToolInspectors = Application.Inspectors
End Sub

Private Sub InitToolInspectors_NewInspector _
    (ByVal Inspector As Outlook.Inspector)
    Set newInspector = Inspector
End Sub

Private Sub newInspector_Activate()
    Dim objNewItem As Object
    Set objNewItem = newInspector.CurrentItem
    If objNewItem.Class = olMail Then
            'Reset toolbar buttons
            ResetButtons
    End If
    Set objNewItem = Nothing
End Sub
Author
27 Sep 2007 7:17 PM
AgapeDisciple
On Sep 27, 2:14 pm, "Ken Slovak - [MVP - Outlook]"
<kenslo***@mvps.org> wrote:
Show quote
> You should test for Inspector.Class = olMail if you only want to handle mail
> items. Then you should have an Inspector declared WithEvents so you can
> handle its events. If you want to handle more than one Inspector you will
> need wrapper classes and a collection to hold the wrapper classes.
>
> Your Inspector object declared WithEvents can then handle the Activate event
> and on the first firing of that event you can call your button procedure,
> don't do it in NewInspector as I said before.
>
> --
> Ken Slovak
> [MVP - Outlook]http://www.slovaktech.com
> Author: Professional Programming Outlook 2007
> Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm
>
> "AgapeDisciple" <AgapeDisci***@gmail.com> wrote in message
>
> news:1190915281.935559.247570@y42g2000hsy.googlegroups.com...
> <snip>
>
>
>
> > Thanks for the info. I implemented the NewInspector, but I'm missing
> > something.  Can you help me out?
>
> > Public WithEvents InitToolInspectors As Outlook.Inspectors
> > Private Sub Application_Startup()
> >    Call Initialize_handler
> > End Sub
> > Public Sub Initialize_handler()
> >    Set InitToolInspectors = Application.Inspectors
> > End Sub
> > Private Sub InitToolInspectors_NewInspector _
> >    (ByVal Inspector As Outlook.Inspector)
> >    'Reset toolbar button on starting New Message
> >    ResetButton
> > End Sub
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -

I couldn't figure out how to do this w/o the NewInspectors, so I put
my code below. The problem is that Outlook crashes whenever I try to
run it. The ResetButton function works fine when I run it using
'Application_ItemSend' but crashes Outlook with this method.

Any ideas?

Public WithEvents InitToolInspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Call Initialize_handler
End Sub

Public Sub Initialize_handler()
    Set InitToolInspectors = Application.Inspectors
End Sub

Private Sub InitToolInspectors_NewInspector _
    (ByVal Inspector As Outlook.Inspector)
    Dim objNewItem As Object
    Set objNewItem = Inspector.CurrentItem
    If objNewItem.Class = olMail Then
        MsgBox "test"
        'Reset SendWithoutSave toolbar button on Send
        ResetButton
    End If
    Set objNewItem = Nothing
End Sub

AddThis Social Bookmark Button