I have a large Excel macro that I turned into an add-in file ( .xlam ), and since I will keep the public version of this add-in on a shared network drive, I followed Ken Pulse's advice from here , using the following code to be able to deploy future versions of my add-in (for updates, patches, etc.) .:
Sub DeployAddIn() 'Author : '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 = "F:\Addins" & 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
Now, I understand what is going on in the code, I'm just not sure where this Sub should be located. Should it be placed in the .xlam module of ThisWorkbook Module1 (which contains my macro) or somewhere else? I am confused because could users who have the add-in have access to this Sub launch? I have the add-in itself blocked, not sure if this helps at all, and I have a button that fits on the add-in toolbar that users can click to run my macro.
vba excel-vba excel add-in
Caffeinatedcoder
source share