Can't writ out a Workbook

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
249
Office Version
  1. 365
Platform
  1. Windows
This is the code:
Code:
Sub Workbook_Save(Path, Workbook_Name, _
                    Optional File_Format As XlFileFormat = xlOpenXMLWorkbookMacroEnabled)
    ' Save the workbook to the indicated file.

    If Right(Path, 1) <> "\" Then Path = Path & "\"
    
    FileName = Path & Workbook_Name
    Workbooks(Workbook_Name).SaveAs _
            FileName:=FileName, _
            FileFormat:=File_Format, _
            CreateBackup:=False
        
End Sub ' Workbook_Save()

Path = "E:\Mac's Data\Mac's Docs on E\Computer\Excel\Spread Sheets\Data Entry"
and when I look at it in File Explorer I get
_______E:\Mac's Data\Mac's Docs on E\Computer\Excel\Spread Sheets\Data Entry
File_Name = "Data Entry (Q).xlsm" and is a new file name.

When I run the code I get an Error 9 (Subscript out of range)

When I run this code via Record Macro
Code:
ActiveWorkbook.SaveAs FileName:= _
        "E:\Mac's Data\Mac's Docs on E\Computer\Excel\Spread Sheets\Data Entry\Data Entry.xlsm" _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
it works.

So whats going on here. Thanks for any help you can give.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Solved: Can't write out a Workbook

The problem is that I was using the File Name as the Workbook Name.

Hope this helps. but many thanks for MrExcel.

Mac
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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