Method 'Save As' of object '_Workbook' failed error when saving to network path

MHamid

Active Member
Joined
Jan 31, 2013
Messages
472
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I am trying to save my file in a network path with a filename provided in a cell. However, I am getting a run-time error '1004': Method 'Save As' of object '_Workbook' failed error.
When I debug is see the code highlighted at this point of the code:
VBA Code:
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum

Below is the full code:
VBA Code:
Sub Create_Final_Version()
'Create the final version

    Dim FileExtStr As String
    Dim wbname As String
    Dim FileFormatNum As Long
    Dim Destwb As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim sh As Worksheet
    Dim year As Integer

    app_functions_ON
    
    FileExtStr = ".xlsm": FileFormatNum = 52
    
    Set Destwb = ActiveWorkbook
    'wbname = Left(Destwb.Name, 25)
    Set sh = Sheets("Control")
    wbname = sh.Range("C16")
    year = sh.Range("B5")
    

    TempFilePath = "\\namicgdfs\cpna_data_grp\IT RMO PBI\Audit and Control\" & year & " Audit Metrics\" & year & " Audit Plan\Audit Plan - Previous - FINAL\"
    TempFileName = wbname
    With Destwb
        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
        '.Close savechanges:=False
    End With

    'MsgBox "You can find the new file in " & TempFilePath
    
    app_functions_OFF
    
End Sub


What did I miss?


Thank you,
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Are you sure that the path is correct, the name is valid, and that you have permission to save to that location?
 
Upvote 0
Yes, the path is valid and I have permission to save since that's where I work out of.

I ended up using the shared drive path itself, but still want to find a way to avoid any issues if someone has mapped their path on a different drive. Is there any way i can ensure a user is saving to the exact shared drive location regardless if it's mapped to N:/ or Z:/ drives?


Thank you,
 
Upvote 0
The code should work as it is if the path is all correct.
 
Upvote 0
That's what I thought too, but for some reason it's not working.
Is there another alternative to ensure the user does not get an error message if the location is mapped to a different drive?
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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