Hi all - I found the below code on this forum and i can make it work if saving the new workbook as .xlsx... but I need to save it as .xlsm however when I try i get run-time error 1004.
how can i solve this? TIA
how can i solve this? TIA
Code:
Sub CreateNewMaster()
Dim FName As String
Dim FPath As String
Dim NewBook As Workbook
Application.ScreenUpdating = False
FPath = Worksheets("main menu").Cells(5, 15).Value
FName = Worksheets("main menu").Cells(6, 15).Value & ".xlsx"
Set NewBook = Workbooks.Add
ThisWorkbook.Sheets("Varun").Copy Before:=NewBook.Sheets(1)
If Dir(FPath & "\" & FName) <> "" Then
MsgBox "File " & FPath & "\" & FName & " already exists"
Else
NewBook.saveas Filename:=FPath & "\" & FName
ActiveWorkbook.Close
End If
End Sub