Can't writ out a Workbook

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
232
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 a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,214,788
Messages
6,121,580
Members
449,039
Latest member
Arbind kumar

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