VBA Handle Temporary Files

wsnyder

Board Regular
Joined
Sep 23, 2018
Messages
223
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Using Excel 365.

I was running my code and it bombed out on me because one of the Source Files was a temporary file "~$...."
If a temporary file is encountered, how can I convert the temporary file to a normal file so code execution may continue?

Thanks,
-w
 

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)
You don't want to do that because there's always a reason for a file to be temporary.
In addition, usually you can't do anything with such temporary files, because they are often blocked by the application that created them.
 
Upvote 0
Thanks,

I opened the offending file in Windows Explorer.
I saved and closed the file.
I re-ran my process and it worked as expected.

The reason it was temporary was because I left it open last night, so when some IT process ran it caused Excel to quit abnormally creating the temp file

I would like to be able to work around this possible future problem so my users do not have the same experience in the future in the likelihood that they leave their files open as well.

Thanks
-w
 
Upvote 0
If you're talking about the temporary and hidden files Excel creates when a workbook is opened - which you didn't tell us ;) - then you can try to delete such a file.
If the corresponding workbook is still open such an attempt will result in an "access denied" and therefore will do no harm.
 
Upvote 0
Solution
Thanks,

I'll try for that approach
The offending workbook is not open.
It is during the opening process that I received the original "~$..."

There are 5 source file that are used in creating a report.
Once the report is created, the source files are closed without saving any changes made during processing since the source file come from IT governed sources/processes and refreshed weekly.

Thanks,
-w
 
Upvote 0
You are welcome and thanks for the feedback (y)
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,795
Members
449,048
Latest member
greyangel23

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