A
Ashley Sutcliffe
Hi all,
It has been a while since I posted my last conundrum. I think it's high
time you had some more brain exercise ...
I have read a number of posts about the OnAction property, but none of
them really address the problem that I am having.
I am using VB 6 with Office/Outlook 2000 and Windows 2000 to create an
Outlook COM addin.
I want to have a number of buttons on a menu bar. The number of buttons
and the properties of these buttons will be determined by information
from a database. I therefore cannot (elegantly) use the WithEvents
keyword and a normal event handler.
The approach that have tried is to set the OnAction property to a sub
that will handle the button click event. Unfortunately, I cannot get
this to work at all.
Here is some very simple source code that demonstrates the problem that
I have:
Option Explicit
Private mOLApp As Outlook.Application
Private MyButton As Office.CommandBarControl
Public Sub ShowMessage()
MsgBox "hello?"
End Sub
Private Sub AddinInstance_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal
AddInInst As Object, custom() As Variant)
Set mOLApp = Application
MsgBox "Confirm that the addin has loaded"
Dim oPop As Office.CommandBarPopup
'I want to use the Actions menu for a mail item
Set oPop = mOLApp.ActiveExplorer.CommandBars("Menu
Bar").FindControl(Id:=30131)
Set MyButton = oPop.Controls.Add(Type:=msoControlButton,
Temporary:=True, Before:=1)
MyButton.Caption = "Test"
MyButton.OnAction = "=ShowMessage"
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
End Sub
Private Sub IDTExtensibility_OnStartupComplete(custom() As Variant)
End Sub
If you try this source code in a simple addin, then nothing will happen
when you click on the button. The Microsoft documentation on this
subject is quite scant and hard to find. The code that I have found all
seems to do exactly what I have done, with, I assume, the notable
exception that it works.
If anyone can point out what I am doing wrong or an alternative way of
achieving my goal, then I would be very grateful.
Regards
Ashley
It has been a while since I posted my last conundrum. I think it's high
time you had some more brain exercise ...
I have read a number of posts about the OnAction property, but none of
them really address the problem that I am having.
I am using VB 6 with Office/Outlook 2000 and Windows 2000 to create an
Outlook COM addin.
I want to have a number of buttons on a menu bar. The number of buttons
and the properties of these buttons will be determined by information
from a database. I therefore cannot (elegantly) use the WithEvents
keyword and a normal event handler.
The approach that have tried is to set the OnAction property to a sub
that will handle the button click event. Unfortunately, I cannot get
this to work at all.
Here is some very simple source code that demonstrates the problem that
I have:
Option Explicit
Private mOLApp As Outlook.Application
Private MyButton As Office.CommandBarControl
Public Sub ShowMessage()
MsgBox "hello?"
End Sub
Private Sub AddinInstance_OnConnection(ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal
AddInInst As Object, custom() As Variant)
Set mOLApp = Application
MsgBox "Confirm that the addin has loaded"
Dim oPop As Office.CommandBarPopup
'I want to use the Actions menu for a mail item
Set oPop = mOLApp.ActiveExplorer.CommandBars("Menu
Bar").FindControl(Id:=30131)
Set MyButton = oPop.Controls.Add(Type:=msoControlButton,
Temporary:=True, Before:=1)
MyButton.Caption = "Test"
MyButton.OnAction = "=ShowMessage"
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
End Sub
Private Sub IDTExtensibility_OnStartupComplete(custom() As Variant)
End Sub
If you try this source code in a simple addin, then nothing will happen
when you click on the button. The Microsoft documentation on this
subject is quite scant and hard to find. The code that I have found all
seems to do exactly what I have done, with, I assume, the notable
exception that it works.
If anyone can point out what I am doing wrong or an alternative way of
achieving my goal, then I would be very grateful.
Regards
Ashley