Creating an addin from an Excel macro.
Conclusion
This article has shown a little bit of what it takes to convert a self built macro to a utility fit for distribution to others. Of course there are many more things to account for when one designs an add-in. Things like changing (and setting back!) Excel-application settings and designing a proper user interface haven't been addressed at al.
Nevertheless, the subjects discussed in this article will certainly get you started to create a professional looking add-in from a simple macro.
Books
To those of you who need more in-depth information, I would very much like to recommend this book:
Professional Excel development
Authors: Stephen Bullen, Rob Bovey and John Green
Published by Addison-Wesley, February 2005.
ISBN: 0321262506
Or:
Excel 2003 Power Programming with VBA (2007 edition soon to be published)
Author: John Walkenbach
Publisher: Wiley
ISBN: 978-0-7645-4072-1
If you're more of a beginner, try the Dummies series:
Excel 2007 VBA Programming for Dummies. (to be published beginning of 2007, there are separate editions for the older Excel versions)
Author: John Walkenbach
Revision author: Jan Karel Pieterse
Publisher: Wiley.
ISBN: 978-0-470-04674-6





Comments
Showing last 8 comments of 33 in total (Show All Comments):Comment by: Tim (5/5/2008 2:16:26 PM)Thanks for the excellent article!
I used the setup code you described on the last page and found that it installs the addin in the C:\Program Files\Microsoft Office\OFFICE11 directory as opposed to the user's addin directory.
If you make the following tweaks to the code, it will install in the user's addin directory instead.
Thanks for the great code! Saved me so much time!
change application.librarypath to application.userlibrarypath (note - you need to take out the extra backslash added on this line:
AddInLibPath = Application.LibraryPath & "\" & sFilename
add the following lines before the
Else
vReply = ... lines
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application line
Set xlwbBook = xlApp.Workbooks.Open(AddInLibPath)
Workbooks.Open (AddInLibPath)
xlApp.AddIns.Add(AddInLibPath, True).Installed = True
Comment by: Jan Karel Pieterse (5/6/2008 12:48:02 AM)Odd. All Path properties Excel exposes do not have the path separator at the end as far as I know, but you are the second one to report it does contain the path separator at the end and hence there is a duplicate \. I need to investigate this!
Comment by: Ajay K Tripathi (7/14/2008 10:27:57 PM)Siply Excellent. I got what I was trying from many weeks.
Thanks a lot.
Comment by: Yusuf Ahmed (6/2/2009 4:14:31 AM)I have several add-ins. Some of my users may need to install two or more of the add-ins. I am having trouble getting the second add-in to go in the tab and group created by the first add-in. Is it possible to add to the same tab and group on the ribbon at different times.
Comment by: Jan Karel Pieterse (6/2/2009 4:47:00 AM)Hi Yusuf,
This is certainly possible, but requires special syntax. This is excellently described in this book: RibbonX by Ken Puls et al. See my books page for a link.
Comment by: Yusuf Ahmed (6/2/2009 11:38:19 PM)Thank You for the information. I found this tutorial very helpful. It got me going on the right track and now I have new questions for which you have provided a reference. Thanks again. This is really helpful.
Comment by: Johnnie Lockett (6/16/2009 12:33:09 PM)This is not only helpful for the subject matter involved — it is also a tutorial on how to properly write tutorials! Over several hours of searching the web, I was able to find only bits and pieces of what you have managed to teach all in one place.
Also, a pet peeve of mine involves the lack of care usually evident on web pages when it comes to literacy, articulation, and spelling. To many, this may be a minor consideration, but I tend to have more confidence in the information being taught when the author is as assiduous as you are about the presentation.
Thank you. Thank you. Thank you.
Comment by: Jan Karel Pieterse (6/17/2009 1:43:23 AM)Hi Johnnie,
Wow, <blush>. Thanks for the compliment, much appreciated!
Have a question, comment or suggestion? Then please use this form.