I've read through other threads on this but can't seem to to piece together what I'm missing. Everything seems to run fine until it gets to the save as line where it throws a type mismatch error. There are steps taken between these two Subs but they seemed the two that are relevant to the issue.
I'm creating a folder and then trying to save a workbook to it. The folder creation works but the save errors out.
Variables Folderuse, Currentmonth, Territory, Currentbook are all defined as strings and all appear to be passing correctly (except for Currentbook which doesn't get to because the error occurs on the Activeworkbook.SaveAs line).
Folderuse = "April 2022"
Currentmonth = "April"
Territory = "TC1 PNW"
Eventually the program is going to be churning out multiple saved files for different geographic regions so I need to save with variables that will count through in the process.
I'm creating a folder and then trying to save a workbook to it. The folder creation works but the save errors out.
Variables Folderuse, Currentmonth, Territory, Currentbook are all defined as strings and all appear to be passing correctly (except for Currentbook which doesn't get to because the error occurs on the Activeworkbook.SaveAs line).
Folderuse = "April 2022"
Currentmonth = "April"
Territory = "TC1 PNW"
Eventually the program is going to be churning out multiple saved files for different geographic regions so I need to save with variables that will count through in the process.
VBA Code:
Sub Makefolder(Folderuse)
Dim fdObj As Object
Application.ScreenUpdating = False
Set fdObj = CreateObject("Scripting.FileSystemObject")
If fdObj.FolderExists("C:\Users\10000\Documents\CI Documents\POS File\Month End Reporting\" & Folderuse) Then
MsgBox "Found it.", vbInformation, "Kutools for Excel"
Else
fdObj.CreateFolder ("C:\Users\10000\Documents\CI Documents\POS File\Month End Reporting\" & Folderuse)
MsgBox "It has been created.", vbInformation, "Kutools for Excel"
End If
Application.ScreenUpdating = True
End Sub
VBA Code:
Sub name(Currentmonth, Territory, Currentbook, Folderuse)
ActiveWorkbook.SaveAs Filename:="C:\Users\10000\Documents\CI Documents\POS File\Month End Reporting\" & Folderuse \ Territory & " Mid Month " & Currentmonth, FileFormat:=51
Currentbook = ActiveWorkbook.name
End Sub