Excel report error (VBA)

G

Guest

I am trying to save a record in a CSV file. Whenever I run the macro, I get
an error:

Run-time error '1004'
Method 'SaveAs' of object '_Workbook' failed

My code for this is:

Sub SaveCSV()
Property = Range("[Control.xls]Info!B2").Value
TodaysDate = Format(Now, "dd-mm-yy")
ActiveWorkbook.SaveAs Filename:="C:\Export\Files\" & Property &
TodaysDate & ".csv", _
FileFormat:=xlCSV, CreateBackup:=False
NewSaveName = Property & TodaysDate & ".csv"
End Sub

Any ideas on how to fix this? Help much appreciated.
 
G

Guest

Yeah, I finally figured that one out after hours of frustration. Thanks for
your reply!
--
Thanks, Dirk


Chip Pearson said:
Your code worked fine for me as long as the folder
C:\Export\Files exists. Are you sure that folder exists?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

message
I am trying to save a record in a CSV file. Whenever I run the
macro, I get
an error:

Run-time error '1004'
Method 'SaveAs' of object '_Workbook' failed

My code for this is:

Sub SaveCSV()
Property = Range("[Control.xls]Info!B2").Value
TodaysDate = Format(Now, "dd-mm-yy")
ActiveWorkbook.SaveAs Filename:="C:\Export\Files\" &
Property &
TodaysDate & ".csv", _
FileFormat:=xlCSV, CreateBackup:=False
NewSaveName = Property & TodaysDate & ".csv"
End Sub

Any ideas on how to fix this? Help much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top