I'm Trying to create a directory in excel-VBA and then copy the xlsm and ,pdf file into this directory.
I can create the directory but I can't seem to save the files into this directory?
Code below. Any Help is much appreciated. This is driving me crazy. All I'm doing is concatenating the filename and it's being saved to the c:\temp folder, but I want it to save it into a sub folder in c:\temp
Sub Macro2()
'
' Macro2 Macro
'
Dim FileName As String
Dim FileName2 As String
'FileName3 As String
FileName = Sheet1.TextBox1.Text
FileName2 = ("C:\TEMP\" & FileName)
'CheckDir As String
MsgBox (FileName2)
MkDir (FileName2)
ChDir (FileName2)
ActiveWorkbook.SaveAs FileName:=FileName2 & FileName & "2xlsm.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
FileName2 & "FileName" & "_2xlsm.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
FileName2 = ("C:\TEMP\FileName\)
– 0m3r