Excel Add-In

M

mju

I just created an excel add-in . I want my users to be able to add it to
their workbook or it should always be there whenever excel workbook is
opened. … Something like the personal workbook.

Also, how do I make it available for the macro to run without the user going
through the VB editor to run the macro? Something like going through the
tools-macro-choose macro name –run or maybe a custom button on the menu or
toolbar

thanks
 
S

Sam Wilson

Save the add-in to a shared location - users can go to tools/add-ins and
browse to your add-in, copying a copy to their C drive when prompted.


To create a menu, use something like the following in the workbook open event:

On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("My Menu").Delete
On Error GoTo 0

Dim wsmb As CommandBar
Dim myMen As CommandBarControl

Set wsmb = Application.CommandBars("Worksheet Menu Bar")
Set myMen = wsmb.Controls.Add(Type:=msoControlPopup, temporary:=True)

With myMen
.Caption = "My Menu"
With .Controls.Add(msoControlButton)
.Caption = "First menu option"
.OnAction = "{macro name}"
End With
With .Controls.Add(msoControlButton)
.Caption = "Second menu option"
.OnAction = "{macro name}"
End With
end with
 
M

mju

Thanks alot Sam!

It works perfectly fine when i open an excel file (xls) but the macro does
not run when i open a csv file in excel. it tells me the macro cannot be
found.
 
M

mju

Thanks alot Sam!

It works perfectly fine when i open an excel file (xls) but the macro does
not run when i open a csv file in excel. it tells me the macro cannot be
found.
 
C

Chip Pearson

.OnAction = "{macro name}"

This should be

..OnAction = "'" & ThisWorkbook.name & "'!MacroName"

This tells Excel where to look for the procedure.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
M

maju maju

thanks Chip!

When you siad workbook name, do you mean the name of the work? Please see below on action code. I am still getting the error.

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("PO_DATA ANALYSIS MACRO").Delete
On Error GoTo 0

Dim wsmb As CommandBar
Dim myMen As CommandBarControl

Set wsmb = Application.CommandBars("Worksheet Menu Bar")
Set myMen = wsmb.Controls.Add(Type:=msoControlPopup, temporary:=True)

With myMen
.Caption = "PO_DATA ANALYSIS MACRO"
With .Controls.Add(msoControlButton)
.Caption = "PLAY"
.OnAction = "'" & PO_data_Current - Week.csv & "'! PO_Summary_Rpt "
' .OnAction = "PO_Summary_Rpt"
End With
' End With
End With




Chip Pearson wrote:

This should be.OnAction = "'" & ThisWorkbook.name & "'!
06-Nov-09

This should b

..OnAction = "'" & ThisWorkbook.name & "'!MacroName

This tells Excel where to look for the procedure

Cordially
Chip Pearso
Microsoft Most Valuable Professiona
Excel Product Group, 1998 - 201
Pearson Software Consulting, LL
www.cpearson.co
(email on web site



wrote:

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
ASP.NET SqlCacheDependency Redux
http://www.eggheadcafe.com/tutorial...8f-e2916fa4a619/aspnet-sqlcachedependenc.aspx
 
D

Dave Peterson

CSV files are plain text (unless you're doing something very strange).

They don't contain macros (or formulas or formatting or all that stuff that
makes excel files useful and pretty.
 
M

maju maju

i just tried this but still same error

..OnAction = "'" & ThisWorkbook.Name & "'!PO_Summary_Rpt"



maju maju wrote:

add -in
06-Nov-09

thanks Chip!

When you siad workbook name, do you mean the name of the work? Please see below on action code. I am still getting the error.

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("PO_DATA ANALYSIS MACRO").Delete
On Error GoTo 0

Dim wsmb As CommandBar
Dim myMen As CommandBarControl

Set wsmb = Application.CommandBars("Worksheet Menu Bar")
Set myMen = wsmb.Controls.Add(Type:=msoControlPopup, temporary:=True)

With myMen
.Caption = "PO_DATA ANALYSIS MACRO"
With .Controls.Add(msoControlButton)
.Caption = "PLAY"
.OnAction = "'" & PO_data_Current - Week.csv & "'! PO_Summary_Rpt "
' .OnAction = "PO_Summary_Rpt"
End With
' End With
End With

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
ASP.NET DropDown ListBox and XML Databinding
http://www.eggheadcafe.com/tutorial...396-3b3ad9b126c9/aspnet-dropdown-listbox.aspx
 

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