thekamel
New Member
- Joined
- Feb 11, 2015
- Messages
- 16
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
- MacOS
- Mobile
- Web
Hello everyone,
I am using a script that will save a file to a specific folder based of a couple of cells. If the folder doesn't exist, the command fails. I cannot figure out how to get it to create the folder if it isn't there. Here is what I am using now:
Sub File_Save()
Dim Path1 As String
Dim Path2 As String
Dim myfilename As String
Dim fpathname As String
Path1 = Range("K278")
Path2 = Range("K279")
myfilename = Range("K280")
fpathname = Path1 & "\" & Path2 & myfilename & ".xlsm"
MsgBox "You are trying to save the file to:" & vbCrLf & fpathname
ActiveWorkbook.SaveAs Filename:=fpathname, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub
Any help is greatly appreciated!
Thank you,
Kamel
I am using a script that will save a file to a specific folder based of a couple of cells. If the folder doesn't exist, the command fails. I cannot figure out how to get it to create the folder if it isn't there. Here is what I am using now:
Sub File_Save()
Dim Path1 As String
Dim Path2 As String
Dim myfilename As String
Dim fpathname As String
Path1 = Range("K278")
Path2 = Range("K279")
myfilename = Range("K280")
fpathname = Path1 & "\" & Path2 & myfilename & ".xlsm"
MsgBox "You are trying to save the file to:" & vbCrLf & fpathname
ActiveWorkbook.SaveAs Filename:=fpathname, FileFormat:=xlOpenXMLWorkbookMacroEnabled
End Sub
Any help is greatly appreciated!
Thank you,
Kamel