Hi all,
I know a very little VBA and I am stuck on this bit of code.
I have a workbook called NTCT_EXPENSE_PAYROLL.xlsm
the spreadsheet name is CSV_FILE
I am trying to automate exporting this spreadsheet to a folder on the C: drive as a CSV file. The folder name is EXPORT
but excel does not like:
wbkExport.SaveAs Filename:="C:\EXPORT.7J1", FileFormat:=xlCSV
Can you help with the correct code to export the spreadsheet named CSV_File to a folder on my C drive named EXPORT? I was also trying to name the file 7J1 ( the payroll batch name)
Please help,
Sharon
I found the code below
Dim NTCT_EXPENSE_PAYROLL As Workbook
Dim CSV_FILE As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("CSV_FILE") 'Sheet to export as CSV
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False 'Possibly overwrite without asking
wbkExport.SaveAs Filename:="C:\EXPORT.7J1", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
I know a very little VBA and I am stuck on this bit of code.
I have a workbook called NTCT_EXPENSE_PAYROLL.xlsm
the spreadsheet name is CSV_FILE
I am trying to automate exporting this spreadsheet to a folder on the C: drive as a CSV file. The folder name is EXPORT
but excel does not like:
wbkExport.SaveAs Filename:="C:\EXPORT.7J1", FileFormat:=xlCSV
Can you help with the correct code to export the spreadsheet named CSV_File to a folder on my C drive named EXPORT? I was also trying to name the file 7J1 ( the payroll batch name)
Please help,
Sharon
I found the code below
Dim NTCT_EXPENSE_PAYROLL As Workbook
Dim CSV_FILE As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("CSV_FILE") 'Sheet to export as CSV
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False 'Possibly overwrite without asking
wbkExport.SaveAs Filename:="C:\EXPORT.7J1", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False