Runtime Error

Holley

Board Regular
Joined
Dec 11, 2019
Messages
155
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello all!

I have a code that runs beautifully "most of the time", however, it will not always overwrite the file 100% of the time. I randomly receive a Runtime Error 1004 Method 'SaveAs' of object'_Workbook' fialed. If I rename or delete the file it works fine.

VBA Code:
 ActiveWorkbook.SaveAs fileName:="\\cd22.abcnet.abc.com\share$\DESK\Report\29sIs.xlsx", FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=True

I have tried to add code to rename the file but get a Run-time error 75, Path/File access error at the Name oldName As newName line.
VBA Code:
Dim oldName As String
Dim newName As String
oldName = "\\cd22.abcnet.abc.com\share$\DESK\Report\29sIs.xlsx"
newName ="\\cd22.abcnet.abc.com\share$\DESK\Report\29sIsBU.xlsx"
Name oldName As newName

I've even tried using the Kill code to delete the file prior to saving and get a Runtime error 70 Permission denied. The file is not open anywhere and I have read and write access so I'm not sure whats preventing the overwrite, delete or renaming.

Any suggestions would be most appreciated!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I'm wondering if a delay in connecting to that drive may be causing your occasional issue? I would try mapping a drive to "\\cd22.abcnet.abc.com\share$\DESK\" then reference the file as "N:\Report\29sIs.xlsx" for example.
 
Upvote 0
I'm wondering if a delay in connecting to that drive may be causing your occasional issue? I would try mapping a drive to "\\cd22.abcnet.abc.com\share$\DESK\" then reference the file as "N:\Report\29sIs.xlsx" for example.
Thanks!! I'll try that and let you know!!
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,171
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