VBA SaveAs function generates blank CSV file

S

Shaoqing Chen

This is a very simple line and it just doesn't work. What it did is just creating a blank csv file with nothing in it (the file name is correct though).


ActiveWorkbook.SaveAs Filename:="C:\temp\test" & ".csv", _
FileFormat:=xlCSV, CreateBackup:=False


And it only happens on one PC. The other PCs runs it perfectly. Can anyone tell why?
 
T

Tim Williams (Theravance)

All PC's are the same version of Excel? It's possible that on the
problem PC the active workbook is not what you think it is...

Tim
 
S

sqchen

I am not sure what you mean. I tried restarting excel and only opening one workbook and it was still the same thing.
 
D

Dave Peterson

Saving a workbook as a CSV file saves only the activesheet.

Maybe the sheet that's active is empty?
 
S

sqchen

No it definitely was not empty. The save to xsl worked fine.

The most stupid thing is, after this line executed I can see the title of the workbook changed to test.csv with full data in it. But when I get out of excel and open the file with notepad it is all empty.
 

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