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
26
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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

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