Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello All,
I have been working with VBA on Mac for about 2yrs now and I just noticed in the last few weeks that code that I had written on several files in the past no longer works and I am not entirely sure why.
The code is listed below
I can confirm that all the qualifiers like the ws1 sheet exist and are spelled correctly. The error I am currently getting is a Error 1004 "Method Saveas of object workbook failed" and it is erroring out on my SaveAs line.
Any help is appreciated in either troubleshooting or rewriting my script.
Thanks in advance
I have been working with VBA on Mac for about 2yrs now and I just noticed in the last few weeks that code that I had written on several files in the past no longer works and I am not entirely sure why.
The code is listed below
VBA Code:
Sub Create_Upload()
Dim RelativePath As String, DT As String, WbNam As String, ws1 As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ws1 = Sheets("Actuals Data")
RelativePath = ThisWorkbook.Path & "/"
DT = Format(CStr(Now), "mm_dd_yyyy hh.mmam/pm")
WbNam = "Submission Template " & " - " & DT 'Creates the File Name
ws1.Copy 'Copies the entire sheet into a new workbook
ActiveWorkbook.SaveAs fileName:=RelativePath & WbNam & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close Save
MsgBox "Submission file saved to the folder where this tool resides."
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I can confirm that all the qualifiers like the ws1 sheet exist and are spelled correctly. The error I am currently getting is a Error 1004 "Method Saveas of object workbook failed" and it is erroring out on my SaveAs line.
Any help is appreciated in either troubleshooting or rewriting my script.
Thanks in advance