Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Hook Excel menu item to sub in VB6 ActiveX dll (Read 1979 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Hook Excel menu item to sub in VB6 ActiveX dll
04.11.09 at 17:01:40
 
Hook Excel menu item to sub in VB6 ActiveX dll
 
To hook an Excel (2002 or higher) menu item to a piece of code inside a VB6 ActiveX dll you need to do the following assuming you have already made the ActiveX dll a COM addin.
 
In a private class module (instancing=1-Private) add the following code:
 
Code:
Dim WithEvents MyMenu As Office.CommandBarButton

Private Sub MyMenu_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    MsgBox "Our Menu CommandBar button was pressed!"
End Sub
 


 
This will be the method Excel calls when the menu item is clicked.
 
Now we need to create the menu item. Assuming m_ctrMenu is a CommandBarControl already initialised you can use something like this:
 
Code:
	  Set MyMenu = m_ctrMenu.Controls.Add(1)
	   With MyMenu
		.Caption = "My Menu Button"
		.Visible = True
	   End With
 

Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1