IMTHEBUS

Tales from my life, learning, teaching and freelancing with MS Excel

AllGuide

Creating an Excel add-in, deploying it to users across a network.

 
addin1

Creating your first Excel add-in can be a daunting task, I put it off for a long time preferring to use modules in standalone workbooks, and the Personal.xlsx workbook. 

If you need a way to update and distribute your code in a managed semi-secure way then the add-in is the route to keep your sanity. I will discuss in another post the route I took to deciding to finally stop keeping all my code fragmented  and learn what I needed to learn to get things in one place. 

The best guide to making the add-in comes from a post on thespreadsheetguru.com step-by-step-instructions-create-first-excel-ribbon-vba-addin, there is no need for me or anyone else to rehash the advice there, it’s extremely good. 

There you will find a wonderful explanation of where to put your code, how to set up the labels, and even a download an example spreadsheet that will automatically set up your toolbar buttons that only needs you to name them and paste your code into modules. It’s pretty foolproof!

You can head over to www.microsoft.com to find a downloadable word document that will list all of the excel icons that can be used by default in your add-in. Be warned, it’s a tedious job to look through them all, and the names must be used exactly as shown. 

If you are looking to deploy this over a network for shared users then next step on the road to salvation is to save this add-in on a networked drive. You will want to keep your copy of the add-in on your local machine, the aim here is you will have a copy that is only on your machine that you can edit without anyone hitting the dreaded debug screen, and a stable copy that your users interact with. 

Your copy should be in a folder similar to;  C:\Users\IMTHEBUS\AppData\Roaming\Microsoft\AddIns

Your distribution copy would be on a shared drive that everyone has access, all the time. The best practice is to set it to Read Only, you can freely not do this, but anytime you need to make even the slightest change you will be forced to shout and call around the office to boot everyone off the system. 

I like Ken Puls code (below) from an older post on www.excelguru.ca, this will act as a deploy button that pushes your add-in from your machine out to the network location and keeps it as a read-only copy. 

Sub DeployAddIn()
‘Author : Ken Puls (www.excelguru.ca)
‘Macro Purpose: To deploy finished/updated add-in to a network
‘ location as a read only file
Dim strAddinDevelopmentPath As String
Dim strAddinPublicPath As String
‘Set development and public paths
strAddinDevelopmentPath = ThisWorkbook.Path & Application.PathSeparator
strAddinPublicPath = “N:\Dean” & Application.PathSeparator
‘Turn off alert regarding overwriting existing files
Application.DisplayAlerts = False
‘Save the add-in
With ThisWorkbook
‘Save to ensure work is okay in case of a crash
.Save
‘Save read only copy to the network (remove read only property
‘save the file and reapply the read only status)
On Error Resume Next
SetAttr strAddinPublicPath & .Name, vbNormal
On Error GoTo 0
.SaveCopyAs FileName:=strAddinPublicPath & .Name
SetAttr strAddinPublicPath & .Name, vbReadOnly
End With
‘Resume alerts
Application.DisplayAlerts = True
End Sub

I link that snippet of code to a button labeled ‘Deploy’ in my add-in that is only set to be visible on my machine. 

whois = Environ(“UserName”)
If whois = “IMTHEBUS” Then           

Select Case control.ID   “aButton01”: MakeVisible = True             

End Select
End if  

Now whenever you make any changes to the local add-in on your machine, you press deploy and a copy is saved in the network location. As a rule, I update the ribbon name with a version number so i can instantly see if users have the most up to date version if they have a problem. I also keep a change log updated that can be called from the add-in so users can see what has been updated. 

Now you have it up and running on your machine, the only thing left to do is to set up the add-in on other machines on the network, and there is an extremely important step not to miss out.  

add-in2

You will be asked if you want to copy the add-in to your personal add-in folder, you do NOT want to do this. Remember the only person who has a local copy of the add-in is you, all other machines need to reach out to the shared network drive to get a copy of the file each time they open Excel. By pressing No here you will make sure that every time the user opens a workbook, they fetch the most up to date version of the add-in.

If you have any questions or comments, feel free to let me know! 

 

The Excel cheat sheet mugs below will give you a head start to becoming a Spreadsheet wizard!

 

2 thoughts on “Creating an Excel add-in, deploying it to users across a network.

  • Helpful article and great blog – thank you! One question: what are some suggestions for when the shared drive is not always accessible? Our team travels regularly and constantly needing to connect to a VPN is not ideal.

    I was thinking along the lines of having the add-in be local and having it “phone home” on occasion when the user is connected to the shared drive to see if there is a new version. If so, download a new copy and replace the local copy.

    Reply
    • Hi Alex,

      Good question! I assume when Excel opens and looks to the network location and does not find the file it would fail to load, perhaps the copy in the cache would remain and be usable? I’ve not tested it but it would make sense, so let’s go with my assumption. I would suggest, in order of complexity…

      1. Program the ‘deploy add-in’ macro to email a copy of the add-in to your users for them to replace it manually, ok if you are only going to make a change a week or thereabouts.
      2. Use a virtual networked drive such as dropbox, every user will need it installed and visible from their file manager.
      3. A bit more complex, but … have your ‘deploy’ button push the file to the network drive, have an additional button named ‘update’ within the add-in. Program this so it copies the file from the network to the local drive and overwrites the file there. Point the excel to this file for the add-in. now whenever they have access to the network they can manually update the file then close and reopen Excel to have the current version. It will also work when out of the office.

      I hope that helps, comment back if you hit any trouble!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.