Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
725 views
in Technique[技术] by (71.8m points)

vba - running a macro from an add-in

i have an add-in called book1. inside the addin there is a module called module1 which has a sub called addin1

i would like to run the macro addin1 from a different workbook

i am trying to call this macro like this:

Call Addin1

but that's not working

and i tried:

Call book1.xlam.Module1.AddIn1

which is not working either

does anyone know how to run a macro that is within an add-in ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

(Assuming Office 2007) Here's an example:

1- Open a new Workbook.
2- Add a macro that contains the code MsgBox("Add-In")
3- Save as xlam file.
4- Open new Workbook.
5- Click Office Button -> Excel Options
6- Click the Add-Ins tab on the left.
7- At the bottom, next to the "Manage" dropdown, select "Excel Add-Ins" and click Go.
8- Click Browse and navigate to your xlam file.
9- Ensure the box next to your file is checked and click Ok.
10- Click the Office Button -> Excel Options.
11- Click Customize Tab.
12- Select Macros in the "Choose Commands From Dropdown."
13- Double click your AddIn and now a button will appear on the Quick Access Toolbar.
14- Click the button and your message box will now show.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...