SOLVED

Urgent Kill Assistance

%3CLINGO-SUB%20id%3D%22lingo-sub-2139641%22%20slang%3D%22en-US%22%3EUrgent%20Kill%20Assistance%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139641%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20running%20a%20VBA%20routine%20that%20creates%20a%20temporary%20PDF%20file%20and%20when%20it%20is%20done%20kills%20it.%20My%20problem%20is%20I%20receive%20an%20error%20access%20denied.%20This%20is%20on%20my%20local%20C%20Documents%20Drive%20it%20is%20not%20a%20security%20issue%20because%20if%20I%20wait%20anywhere%20between%2010-30%20seconds%20the%20process%20will%20move%20forward%20and%20delete%20the%20temp%20file.%20When%20I%20export%20the%20file%20I%20am%20exporting%20it%20as%20a%20pdf%20using%20.ExportAsFixedFormat%20with%20OpenAfterPublish%20set%20to%20False.%20So%20I%20do%20not%20know%20what%20is%20taking%20place%20before%20the%20kill%20will%20recognize%20the%20file%20and%20delete%20it.%20I%20really%20do%20not%20want%20to%20use%20the%20Wait%20procedure%20as%20that%20would%20take%20too%20long.%20Is%20there%20a%20different%20approach%20I%20can%20take%20that%20will%20allow%20me%20to%20kill%20this%20temp%20file%20fast%20without%20waiting%3F%20Note%3A%20When%20I%20used%20this%20same%20code%20a%20year%20ago%20I%20did%20not%20have%20this%20issue.%20So%20I%20am%20not%20sure%20what%20has%20changed%20to%20cause%20this%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2139641%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

I am running a VBA routine that creates a temporary PDF file and when it is done kills it. My problem is I receive an error access denied. This is on my local C Documents Drive it is not a security issue because if I wait anywhere between 10-30 seconds the process will move forward and delete the temp file. When I export the file I am exporting it as a pdf using .ExportAsFixedFormat with OpenAfterPublish set to False. So I do not know what is taking place before the kill will recognize the file and delete it. I really do not want to use the Wait procedure as that would take too long. Is there a different approach I can take that will allow me to kill this temp file fast without waiting? Note: When I used this same code a year ago I did not have this issue. So I am not sure what has changed to cause this issue.

3 Replies
best response confirmed by heylookitsme (Contributor)
Solution

@heylookitsme 

What do you do with the PDF file between its creation and the attempt to delete it?

After the temp file is created it is saved to a network folder (not my C Drive) which is what is causing the issue. The network is really slow. Your post helped solve the issue. Thanks
What I did to fix the issue was re-route the files being saved to the network to my Local Drive. Which then made everything much faster. I will copy the files over to the network when I am done.