Home All Groups Group Topic Archive Search About
Author
20 Nov 2004 7:52 AM
Michael Bauer
Please declare objCommandBarButton WithEvents in the head of
ThisOutlookSession or another non-standard modul. Then add the event
procedure to your code.

<sample>
Private WithEvents objCommandBarButton As Office.CommandBarButton

Private Sub objCommandBarButton_Click()
' ...
End Sub
</sample>

--
Viele Grüße
Michael Bauer


Show quote
"RB Smissaert" <bartsmissa***@blueyonder.co.uk> wrote in message
news:OMjooJozEHA.1204@TK2MSFTNGP10.phx.gbl...
> Using Outlook 2002
>
> Have some simple code that adds a CommandBarButton to the OL menubar.
> The button appears fine, but pressing it doesn't run the Sub.
>
> Sub MakeMenu()
>
>     Dim objCommandBar As Office.CommandBar
>     Dim objCommandBarButton As Office.CommandBarButton
>
>     Set objCommandBar = Application.ActiveExplorer.CommandBars("Menu
Bar")
>     Set objCommandBarButton =
> objCommandBar.Controls.Add(Type:=msoControlButton)
>
>     With objCommandBarButton
>         .FaceId = 99
>         .Style = msoButtonIconAndCaption
>         .Caption = "New Task"
>         .OnAction = "MakeNewTask"
>     End With
>
> End Sub
>
> Any idea what could be wrong here?
>
>
> RBS
>

Author
20 Nov 2004 8:58 AM
RB Smissaert
Thanks, I had figured that out.
Just wonder why the OnAction property doesn't work.
Would it work if I declared and set the button differently?

RBS


Show quote
"Michael Bauer" <mi***@t-online.de> wrote in message
news:eksMvjtzEHA.3376@TK2MSFTNGP12.phx.gbl...
> Please declare objCommandBarButton WithEvents in the head of
> ThisOutlookSession or another non-standard modul. Then add the event
> procedure to your code.
>
> <sample>
> Private WithEvents objCommandBarButton As Office.CommandBarButton
>
> Private Sub objCommandBarButton_Click()
> ' ...
> End Sub
> </sample>
>
> --
> Viele Grüße
> Michael Bauer
>
>
> "RB Smissaert" <bartsmissa***@blueyonder.co.uk> wrote in message
> news:OMjooJozEHA.1204@TK2MSFTNGP10.phx.gbl...
>> Using Outlook 2002
>>
>> Have some simple code that adds a CommandBarButton to the OL menubar.
>> The button appears fine, but pressing it doesn't run the Sub.
>>
>> Sub MakeMenu()
>>
>>     Dim objCommandBar As Office.CommandBar
>>     Dim objCommandBarButton As Office.CommandBarButton
>>
>>     Set objCommandBar = Application.ActiveExplorer.CommandBars("Menu
> Bar")
>>     Set objCommandBarButton =
>> objCommandBar.Controls.Add(Type:=msoControlButton)
>>
>>     With objCommandBarButton
>>         .FaceId = 99
>>         .Style = msoButtonIconAndCaption
>>         .Caption = "New Task"
>>         .OnAction = "MakeNewTask"
>>     End With
>>
>> End Sub
>>
>> Any idea what could be wrong here?
>>
>>
>> RBS
>>
>
Author
20 Nov 2004 10:40 AM
RB Smissaert
Found out that this method works fine after you have just made the button,
but after closing Outlook and
restarting it clicking the button doesn't fire the Sub anymore.
Maybe it needs a class module.

RBS


Show quote
"Michael Bauer" <mi***@t-online.de> wrote in message
news:eksMvjtzEHA.3376@TK2MSFTNGP12.phx.gbl...
> Please declare objCommandBarButton WithEvents in the head of
> ThisOutlookSession or another non-standard modul. Then add the event
> procedure to your code.
>
> <sample>
> Private WithEvents objCommandBarButton As Office.CommandBarButton
>
> Private Sub objCommandBarButton_Click()
> ' ...
> End Sub
> </sample>
>
> --
> Viele Grüße
> Michael Bauer
>
>
> "RB Smissaert" <bartsmissa***@blueyonder.co.uk> wrote in message
> news:OMjooJozEHA.1204@TK2MSFTNGP10.phx.gbl...
>> Using Outlook 2002
>>
>> Have some simple code that adds a CommandBarButton to the OL menubar.
>> The button appears fine, but pressing it doesn't run the Sub.
>>
>> Sub MakeMenu()
>>
>>     Dim objCommandBar As Office.CommandBar
>>     Dim objCommandBarButton As Office.CommandBarButton
>>
>>     Set objCommandBar = Application.ActiveExplorer.CommandBars("Menu
> Bar")
>>     Set objCommandBarButton =
>> objCommandBar.Controls.Add(Type:=msoControlButton)
>>
>>     With objCommandBarButton
>>         .FaceId = 99
>>         .Style = msoButtonIconAndCaption
>>         .Caption = "New Task"
>>         .OnAction = "MakeNewTask"
>>     End With
>>
>> End Sub
>>
>> Any idea what could be wrong here?
>>
>>
>> RBS
>>
>

AddThis Social Bookmark Button

Post Other interesting topics