Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you take a vba addin and make an installer?

Tags:

excel

vba

vb6

I have written a vba module that installs an addin button to excel. I would like to deploy it on many computers as easy as possible. Currently, these are my steps.

  1. Save the excel as *.xlsm
  2. Open the doc on the computer that I want to install
  3. Save the document as an extension (*.xlam) which places it in the addin folder
  4. Go to options>Add-Ins>Manage /Go>
  5. Click the check box for my add in

Is there a way to automate this process? Write something in vb?

like image 297
Cameron Aziz Avatar asked Aug 23 '13 07:08

Cameron Aziz


People also ask

How do you add macro Add in in Excel?

Right-click the control, and then click Assign Macro. The Assign Macros dialog box appears. To specify the location of an existing macro, select where the macro is located in the Macros in box by doing one of the following: To search for the macro in any workbook that is open, select All Open Workbooks.


3 Answers

You can build an exe or msi installer with a tool such as Advanced Installer (the free edition). One thing you can do is copy files to a specific location and if you put it in the XLSTART folder then that add-in will automatically load for the user when starting Excel. There's a complimentary folder within the Excel program files directory, usually something like this

C:\Program Files (x86)\Microsoft Office\Office15\XLSTART

which if you drop xlam files into that folder they'll load by default too. The user specific option is

C:\Users[UserName]\AppData\Roaming\Microsoft\Excel\XLSTART

there are PROS/CONS to both models. One is will all users have access or just the user that installs. The benefit of the user specific option is it requires limited rights for installation (no admin privileges)

like image 172
Peter Avatar answered Oct 16 '22 15:10

Peter


As others have said, you can easily copy the files to the needed folder in each users Apps directory. They will then need to check the box in the Add-Ins menu, but at least the file will be there. I use this at work with some success by putting the Add-ins and .bat file on a shared drive that everybody has access to. You can then just provide a link to the .bat file which will copy the file from the shared drive to the person's computer in their Apps directory. Here's an example .bat that I use:

xcopy "\\server\share\folder\Addins\CRWScleanup.xlam" "%APPDATA%\Microsoft\AddIns\" /y

Initially I had the .bat files setup to detect and handle Win7 and WinXP because we have a mix at work, but then I realized that the folder location after %APPDATA% (which leads to a different place for XP vs Win7) is the same for each version of Windows. I.e. \Microsoft\AddIns\ %APPDATA% is a global Windows variable and its value will vary for each user (that is good).

It works brilliantly once the Add-In is installed because to update it all I have to do is put the new version on the shared drive and have the user click the link to the .bat while Excel is closed. The new version gets copied over and the user doesn't have to do anything.

like image 2
jerussell Avatar answered Oct 16 '22 16:10

jerussell


With VBA you have to rely on Office files (Excel ones, in this case) and cannot move to executables/installation packages. You might create a program (or a macro) performing the steps you want in an automated way. But if what you want is relying on a standard installation package, which the user might execute (as usual, when installing a program), you would have to move to VB.NET.

VB.NET and VBA are not too different (well... actually, VB.NET includes many more things, but "understands" most of the VBA code) and VB.NET is quite programmer friendly; so a conversion from VBA to VB.NET wouldn't take you too long. In VB.NET you have different ways to interact with Excel; from your question, I understand that you want the Add-in alternative: it generates a custom "installation package" which, once clicked, will install the give Excel Add-in in the target computer. Relying on this option is easy: in your Visual Studio (you need a VS to work with VB.NET), open "New Project" and, within the Visual Basic Templates, select Office (, your version) and Excel Add-in.

NOTE: useful link provided my Mehow: it refers to an old VS (2008) but things haven't changed too much since then.

NOTE 2: the aforementioned suggestion is available in any fee-based VS version since the 2008 one. Not sure about the support in free versions (Express ones).

like image 1
varocarbas Avatar answered Oct 16 '22 16:10

varocarbas