Can't writ out a Workbook

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
117
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.
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
117
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
 

Watch MrExcel Video

Forum statistics

Threads
1,100,142
Messages
5,472,754
Members
406,835
Latest member
steve43040

This Week's Hot Topics

Top