Cell context menu in XL2007

M

Madiya

As I understand from various postings in this forum, we can not create
any custom toolbars or icons in xl2007.
But Is it possible to add custom icon to run a macro in cell context
menu (cell right click menu) by a add-in in VB6?
If yes pl point me to a sample code if available.

I am trying to make com addin in vb6 with help of example on Chip's
site and need to provide a button in rightclick menu to users for
accessing the code.

Regards,
Madiya
 
M

Madiya

See this page for example codehttp://www.ozgrid.com/VBA/right-click.htm

--
Regards







- Show quoted text -

Well, Thanks.
I know this part of code.
I requested sample code for use in com add-in.
I have tried saveral combinations but com add-in is not creating the
custom button in the cell right click menu.
However, all the functions in the same add-in as provided by chip
works fine.

Regards,
Madiya
 
B

Bob Phillips

Madiya,

Can you post the COM addin code, just the necessary implementation code and
the menu code?

--

HTH

Bob

See this page for example codehttp://www.ozgrid.com/VBA/right-click.htm

--
Regards







- Show quoted text -

Well, Thanks.
I know this part of code.
I requested sample code for use in com add-in.
I have tried saveral combinations but com add-in is not creating the
custom button in the cell right click menu.
However, all the functions in the same add-in as provided by chip
works fine.

Regards,
Madiya
 
M

Madiya

Madiya,

Can you post the COM addin code, just the necessary implementation code and
the menu code?

--

HTH

Bob






Well, Thanks.
I know this part of code.
I requested sample code for use in com add-in.
I have tried saveral combinations but com add-in is not creating the
custom button in the cell right click menu.
However, all the functions in the same add-in  as provided by chip
works fine.

Regards,
Madiya- Hide quoted text -

- Show quoted text -

Sure. Here it is.

Connectexcel class module :
'FROM
'http://www.cpearson.com/Excel/CreatingCOMAddIn.aspx

'REFERANCES REQUIRED FOR THIS ADDIN
'C:\Program Files\Common Files\microsoft shared\OFFICE11\MSO.DLL
'C:\Program Files\Office2003\OFFICE11\EXCEL.EXE
'C:\Program Files\Common Files\Designer\MSADDNDR.DLL

Option Explicit
Implements AddInDesignerObjects.IDTExtensibility2


Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
' not used but required by Implements.
End Sub

Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
' not used but required by Implements.
End Sub

Private Sub IDTExtensibility2_OnConnection(ByVal Application As
Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
''''''''''''''''''''''''''''''
' Called automaticaly when Excel loads the CAI.
''''''''''''''''''''''''''''''
Set XL = Application
Set ThisCAI = AddInInst
Set ExcelEvents = New CExcelEvents
End Sub

Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
''''''''''''''''''''''''''''''
' Called automaticaly when Excel unloads the CAI.
''''''''''''''''''''''''''''''
Set XL = Nothing
Set ThisCAI = Nothing
Set ExcelEvents = Nothing
End Sub

Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
' not used but required by Implements.
End Sub

In Cexcelevents class module ;
Private Sub SetupControls()
''''''''''''''''''''''''''''''''''''''''''''''''''''
' Setup one control. Repeat this code for all other
' user interface elements.
''''''''''''''''''''''''''''''''''''''''''''''''''''

'Set pMenuItem1 = XLApp.CommandBars("CELL").Controls.Add( _
' Type:=msoControlButton, Temporary:=True)
With XLApp.CommandBars("Cell").Controls.Add
With .Add(Temporary:=True)
'With pMenuItem1
.Caption = "excel GSM"
.OnAction = "excel GSM"
.Tag = excelGSM
'.BeginGroup = True
End With
End With
pControlsColl.Add pMenuItem1

End Sub

Private Sub pMenuItem1_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
MsgBox "Menu Item Click From Excel COM Add In"
End Sub
 
M

Madiya

Sure. Here it is.

Connectexcel class module :
'FROM
'http://www.cpearson.com/Excel/CreatingCOMAddIn.aspx

'REFERANCES REQUIRED FOR THIS ADDIN
'C:\Program Files\Common Files\microsoft shared\OFFICE11\MSO.DLL
'C:\Program Files\Office2003\OFFICE11\EXCEL.EXE
'C:\Program Files\Common Files\Designer\MSADDNDR.DLL

Option Explicit
Implements AddInDesignerObjects.IDTExtensibility2

Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
' not used but required by Implements.
End Sub

Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
' not used but required by Implements.
End Sub

Private Sub IDTExtensibility2_OnConnection(ByVal Application As
Object, _
    ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
    ByVal AddInInst As Object, custom() As Variant)
    ''''''''''''''''''''''''''''''
    ' Called automaticaly when Excel loads the CAI.
    ''''''''''''''''''''''''''''''
    Set XL = Application
    Set ThisCAI = AddInInst
    Set ExcelEvents = New CExcelEvents
End Sub

Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
    ''''''''''''''''''''''''''''''
    ' Called automaticaly when Excel unloads the CAI.
    ''''''''''''''''''''''''''''''
    Set XL = Nothing
    Set ThisCAI = Nothing
    Set ExcelEvents = Nothing
End Sub

Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
' not used but required by Implements.
End Sub

In Cexcelevents class module ;
Private Sub SetupControls()
    ''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Setup one control. Repeat this code for all other
    ' user interface elements.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''

'Set pMenuItem1 = XLApp.CommandBars("CELL").Controls.Add( _
'        Type:=msoControlButton, Temporary:=True)
With XLApp.CommandBars("Cell").Controls.Add
       With .Add(Temporary:=True)
        'With pMenuItem1
        .Caption = "excel GSM"
        .OnAction = "excel GSM"
        .Tag = excelGSM
        '.BeginGroup = True
    End With
End With
pControlsColl.Add pMenuItem1

End Sub

Private Sub pMenuItem1_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
    MsgBox "Menu Item Click From Excel COM Add In"
End Sub- Hide quoted text -

- Show quoted text -

Pl help.
Madiya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top