Save Workbook Error Microsoft Excel cannot access the file

martipe1

Board Regular
Joined
Mar 16, 2007
Messages
71
I'm trying to save a new workbook and I get the following error:

Run-time error 1004
Microsoft Excel cannot access the file 'C:\6A3EF000".

The code is:

Dim WB As Workbook
Set WB = Workbooks.Add

WB.SaveAs "C:\Report.xlsx"

I also tried:
ActiveWorkbook.SaveAs "C:\Report.xlsx"

Same result, just the file name changes in the error message because is creating a new workbook.

Any idea of what can be wrong?

Thanks
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
The main issue is that C drive is denying you access. So you have to save it in Documents, Desktop, etc. And it's really a good idea if you append , 61 since you want to save as a .xlsx file extension type. (See XlFileFormat enumeration (Excel) . )

(Of course change the file path to your computer's. (Remove "Chris".)
VBA Code:
Sub Save_New_Workbook()

Dim WB As Workbook
Set WB = Workbooks.Add
WB.SaveAs "C:\Users\Chris\Desktop\My Novel\Report.xlsx", 61
Set WB = Nothing

End Sub
 
Upvote 0
Solution
The main issue is that C drive is denying you access. So you have to save it in Documents, Desktop, etc. And it's really a good idea if you append , 61 since you want to save as a .xlsx file extension type. (See XlFileFormat enumeration (Excel) . )

(Of course change the file path to your computer's. (Remove "Chris".)
VBA Code:
Sub Save_New_Workbook()

Dim WB As Workbook
Set WB = Workbooks.Add
WB.SaveAs "C:\Users\Chris\Desktop\My Novel\Report.xlsx", 61
Set WB = Nothing

End Sub
Thank you very much for your answer and solution, didn't think c drive was not accessible, I changed to temp directory and kill the file at the end.

I used in the end ActiveWorkbook.SaveAs to save my file and I believe file extension type doesn't apply.

Just one more question. Why use type 61 and not 51?

Thanks!!
 
Upvote 0
Thank you very much for your answer and solution, didn't think c drive was not accessible, I changed to temp directory and kill the file at the end.

I used in the end ActiveWorkbook.SaveAs to save my file and I believe file extension type doesn't apply.

Just one more question. Why use type 61 and not 51?

Thanks!!
You are correct, it should be 51. (Sorry. I saw .xlsx 10 lines too late!) See Save Workbook As for a second opinion which agrees.
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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