Hello,
I keep receiving RunTime Error 1004 at the saveAs line of my code. The code is below. I have tried multiple different solutions people have posted, but it doesn't help.
---> rest of code
The value of C27 is the file path inputted by user
The value of C2 is the type of summary needed also inputted by user
I keep receiving RunTime Error 1004 at the saveAs line of my code. The code is below. I have tried multiple different solutions people have posted, but it doesn't help.
VBA Code:
Private Sub CommandButton1_Click()
Dim Path As String
Dim Name As String
Dim Loc As String
Set wb = Workbooks.Add
ThisWorkbook.Activate
Application.Calculate
If Not Application.CalculationState = xlDone Then
DoEvents
End If
Path = ThisWorkbook.Sheets("Sheet1").Range("C27").Value
Name = ThisWorkbook.Sheets("Sheet1").Range("C2").Value & "_" & Format(Date, "ddmmyyyy") & "_" & Format(Time, "hh:mm:ss")
Loc = Path & "\" & Name & ".xlsm"
ThisWorkbook.Sheets("Summary").Copy Before:=wb.Sheets(1)
wb.Activate
ActiveWorkbook.SaveAs FileName:=Path & "\" & Name & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
The value of C27 is the file path inputted by user
The value of C2 is the type of summary needed also inputted by user