Saving a XLAM file (from within it's own code) leaves a temp copy in the directory

BenW71

New Member
Joined
Apr 19, 2018
Messages
28
I have an xlam (excel add-in macro) file that has a hidden worksheet in it. If the user does something to change the values within that worksheet, I have to save the addinfile so that it is available in the future i believe.

In order to save the xlam, i have the following function:

VBA Code:
Public Sub SaveAddIn()
Dim strFileName As String
On Error Resume Next

    strFileName = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".", -1, vbTextCompare) - 1))    'Get the name part without the rest so it can be saved...
    ThisWorkbook.IsAddin = True    'There are scenarios that has the worksheet visible for editing, so i assert it back to being an addin and re-hide the worksheet
    ThisWorkbook.SaveAs fileName:=ThisWorkbook.Path & "\" & strFileName & ".xlam", FileFormat:=xlOpenXMLAddIn  'THIS IS WHERE THE FILE IS SAVED AND THE TEMP FILE IS LEFT BEHIND.  I am letting each user decide where to leave it, NOT in the default MS location for addins...
End Sub

In the SaveAs call above, it creates these temporary files that are left behind in the directory where the file is being saved.

1705700970032.png


Does anyone know why that is being created and not cleaned up?

Also this saving step takes about 30 seconds. Is that expected?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

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