Reputation: 1
What is the issue with the code below? I am receiving the runtime 1004 error.
Sub Save_CSV()
'
' Save_CSV Macro
'
'
Columns("A:K").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ThisWorkbook.SaveAs Filename:= _
"G:\Business & Facility\Finance\Finance Documents\Payroll Journal\EH Payroll Journal IMPORT.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
Windows("EH Payroll Journal TEMPLATE Xero.xlsm").Activate
End Sub
Upvotes: 0
Views: 85
Reputation: 23974
Assuming ThisWorkbook
is "EH Payroll Journal TEMPLATE Xero.xlsm", then once you have done the ThisWorkbook.SaveAs
you will no longer be able to activate the window containing it, because you have saved it as "EH Payroll Journal IMPORT.csv".
You are probably wanting to do a ActiveWorkbook.SaveAs
instead, to save the newly added workbook to which you copied data.
Upvotes: 1