Save Workbook Error Microsoft Excel cannot access the file

martipe1

Board Regular
Joined
Mar 16, 2007
Messages
69
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

cmowla

Board Regular
Joined
Sep 21, 2021
Messages
243
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

martipe1

Board Regular
Joined
Mar 16, 2007
Messages
69
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!!
 

cmowla

Board Regular
Joined
Sep 21, 2021
Messages
243
Office Version
  1. 365
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,147,452
Messages
5,741,209
Members
423,649
Latest member
steel1968

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
Top