How to overwrite the currently used add-in with a newer version of itself

Bassie

Board Regular
Joined
Jan 13, 2022
Messages
66
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone,

I got most of my question in place, the add-in checks if there is a newer version and will get that newer version from the server if needed. The only thing I am struggling now is to replace the older add-in with the newer add-in while the names of both add-ins stay the same.

So at the moment there is a add-in called "XYZ" in the users add-in folder, I want to replace this with another add-in also called "XYZ" but this add-in is an updated one. How can I do this within the add-in itself?

Any help would be greatly appriciated,
Bassie
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi Bassie. Maybe something like this...
Code:
Dim Fso As Object, SrcFolderStr As String, DestFolderStr As String
Set Fso = CreateObject("scripting.filesystemobject")
SrcFolderStr = "C:\YourFolderName\AddinTestName.xlsm"
DestFolderStr = Application.UserLibraryPath & "AddinTestName.xlam"
Fso.CopyFile SrcFolderStr, DestFolderStr, True  'source,destination,save
Set Fso = Nothing
Change SrcFolderStr to suit your file path and DestFolderStr to your addin name. HTH. Dave
 
Upvote 0
Hi Dave,

Thanks for the help!

I changed the srcfolderstr and DestFolderStr but at the moment the sub runs but I am not sure if it is doing anything, it is not giving errors either.

- Bassie
 
Upvote 0
Nevermind I made a mistake, it is working but it is not working when the add-in is open already.

Is it possible to run this code from the old add-in and then replace the old add-in with the new one? At the moment when i try I get a run-time error 70 that the permission is denied

Regards
Bassie
 
Upvote 0
The permission denied is because the add in is open. Not real sure but if your code was to create a new temp wb, close the addin wb while maintaining the same XL process, then run the code above, re-open the new addin wb and close the temp wb, it might work. I don't have too much time to contribute right now, so give it a go and I'll check back in when I'm able. Good luck. Dave
 
Upvote 1
Ive been trying some more things and where I am stuck now is the following:

I removed the old add-in while installing the new add-in, the only problem I have now is that I want this new add-in to have the exact same name as the old add-in. Do you have any ideas on how to conquer this problem?

Regards,
Bassie
 
Upvote 0
You could rename it , very easy in VBA:
VBA Code:
 Name src As dst
where scr is the fullpath of the source and destination is the full path of the destination
 
Upvote 0
You could rename it , very easy in VBA:
VBA Code:
 Name src As dst
where scr is the fullpath of the source and destination is the full path of the destination
Does this also work on the add-in that is currently open?
 
Upvote 0
No I don't think so , you will need to close it, I can see that could be the problem when you are trying to run the code from the ADDIn!! I think you will need to run a shell script which could close EXCEL, rename then addIN the start excel again
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,180
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top