Good Morning!
I have an excel file - with multiple tabs generated via power query - that i would now like to convert those individual tabs to CSV. For every CSV file created - changes the name of the active file to my designated csv name. Then at the end - I want to save the file back to the original name. However I get an error message with multiple potential reasons -
I have an excel file - with multiple tabs generated via power query - that i would now like to convert those individual tabs to CSV. For every CSV file created - changes the name of the active file to my designated csv name. Then at the end - I want to save the file back to the original name. However I get an error message with multiple potential reasons -
Code:
Sub SaveFiles()
'
' SaveFiles Macro
'
Application.DisplayAlerts = False
Dim MasterDirectory As String
' MasterDirectory = ActiveWorkbook.Sheets("DirectorySetup").Range("A4")
Dim MasterFileName As String
MasterFileName = ActiveWorkbook.Sheets("DirectorySetup").Range("C4") & ".xlsm"
Dim FBSImportDirectory As String
FBSImportDirectory = ActiveWorkbook.Sheets("DirectorySetup").Range("A7")
Range("D1").Select
ActiveWorkbook.Save
Sheets("PackerImport").Select
Range("A2").Select
ChDir "C:\FBSPacker\FBSImportFiles"
ActiveWorkbook.SaveAs Filename:= _
FBSImportDirectory & "PackerImport" & ".csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Name = "PackerImport"
Sheets("GroupMap").Select
Range("D1").Select
ChDir "C:\FBSPacker"
ActiveWorkbook.SaveAs Filename:=MasterDirectory & MasterFileName, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.DisplayAlerts = True
MsgBox Prompt:="Files Saved"
End Sub