Working with Excel - AddIns

24 views
Skip to first unread message

Harry

unread,
May 8, 2011, 1:51:48 AM5/8/11
to MS Excel Macro Vba
Hi Group,

My question is with regards to "Excel Add-ins".

Laltely i learnt about Add-Ins, however i have the following questions
on them:

1) Can we store a Worksheet within Excel-Addin file, which can be
latter be brought to sight when the user runs a macro stored inside
the Excel Add-in

Scenario:
I created a ADD-In file which consists of all the macro i want to
provide to the users. The Excel Add-In also has a code which creates a
custom menu on the Commandbars.
There are particular Excel Worksheet(s) which are used by many users
for ready reference. I want to save these within the Excel ADD-In
Workbook, so that i can call these workbooks through macro. Is it
possible to do so?

As of now i have saved the reference sheets as a seaprate workbook,
which is opened everytime the user wants to refer to any one of those
sheets.

Cheers
Harry

rf1234 rf1234

unread,
May 10, 2011, 1:45:59 AM5/10/11
to exce...@googlegroups.com

You can save your workbook with multiple Excel Add-in.

One of the best options is to add Menu Bar. In menu bar

You can define your Add-in, where you can perform action

After mouse click Event.

‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’

With cmbControl

        .Caption = "&My Macros" 'names the menu item

    With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item

        .Caption = "My Macro No 1" 'adds a description to the menu item

        .OnAction = "RunMyMacro1" 'runs the specified macro

        .FaceId = 1098 'assigns an icon to the dropdown

    End With

        With .Controls.Add(Type:=msoControlButton)

            .Caption = "My Macro No 2"

            .OnAction = "RunMyMacro2"

            .FaceId = 108

            .MsgBox "Sample Macro2"

        End With

            With .Controls.Add(Type:=msoControlButton)

                .Caption = "My Macro No 3"

                .OnAction = "RunMyMacro3"

                .FaceId = 21

                .MsgBox "Sample Macro3"

            End With

    End With

 

 

‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’

 

 

‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’

‘’Full Code’’’’’’’’’’’’’

’’’’’’’’’’’’’’’’’’’’’’’’’’’’’

 

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)

On Error Resume Next 'in case the menu item has already been deleted

Application.CommandBars("Worksheet Menu Bar").Controls("My Macros").Delete 'delete the menu item

End Sub

 

Private Sub Workbook_Open()

Dim cmbBar As CommandBar

Dim cmbControl As CommandBarControl

 

Set cmbBar = Application.CommandBars("Worksheet Menu Bar")

Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, temporary:=True) 'adds a menu item to the Menu Bar

    With cmbControl

        .Caption = "&My Macros" 'names the menu item

    With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item

        .Caption = "My Macro No 1" 'adds a description to the menu item

        .OnAction = "RunMyMacro1" 'runs the specified macro

        .FaceId = 1098 'assigns an icon to the dropdown

    End With

        With .Controls.Add(Type:=msoControlButton)

            .Caption = "My Macro No 2"

            .OnAction = "RunMyMacro2"

            .FaceId = 108

            .MsgBox "Sample Macro2"

        End With

            With .Controls.Add(Type:=msoControlButton)

                .Caption = "My Macro No 3"

                .OnAction = "RunMyMacro3"

                .FaceId = 21

                .MsgBox "Sample Macro3"

            End With

    End With

End Sub

 






--
You received this message because you are subscribed to the Google Groups "MS Excel Macro Vba" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to excel_vba+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/excel_vba?hl=en.




--
Regards,
Prashant Tripathi
Engineer-SW
Mobile: 0017202597567
Please consider the environment before printing.
----------------------------------------------------
Immer zielen auf die vollkommene Harmonie des
 Denkens & Wort & deed.Always zielen darauf ab,
 reinigen Sie Ihre Meinung und alles wird gut.
 ----------------------------------------------------
Always aim at complete harmony of thought &
 word & deed.Always aim at purifying your
thoughts & everything will be well.

Reply all
Reply to author
Forward
0 new messages