Method 'SaveAs' of object'_Workbook' failed error

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
701
Office Version
  1. 365
Platform
  1. Windows
I'm having some trouble saving spreadsheets on a network drive. I've looked all over Google (on the sites my work laptop will allow me to access), and searched through Mr. Excel, but haven't found anything. I'm using a macro enabled document to open a .xlsx document, complete some fields, then I want to save the .xlsx document on a network drive, using the value of cell K7 as the file name.

VBA Code:
fPath = [URL='https://www.mrexcel.com/board/file://%5C%5CServer%5CFolder%5C']\\Server\Folder\[/URL]
fName = sMS1.Range("K7").Value & ".xlsx"
s.SaveAs fPath & fName

When I run the code, I'm getting a Run-time error '1004': Method 'SaveAs' of object'_Workbook' failed error.

I'm not sure if the value in cell K7 having preceding zeroes could be the issue. Both fPath and fName are declared as string
 
I'm using a .xlsm file to open a .xlsx file that I want to save as a .xlsx file.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
@reberryjr Record yourself manually recording a saveas to the location and post the code it produces in the thread then put
VBA Code:
Debug.Print fPath & fName
in the code and Copy/Paste the result it produces in the thread.

Please note also that you are declaring your variables incorrectly. In VBA you need to explicitly declare each variables type or they default to Variant.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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