SaveAs method of workbook class failed

Posted on 2007-10-17
Last Modified: 2012-08-13
When I am trying to save a workbook as a .csv file I get the Saveas method failed.

My code is:  xlsFile.Application.ActiveWorkBook.SaveAs Filename:="c:\test.csv", FileFormat:=xlCSV.

If I don't use the FileFormat parameter, the saveas works, but I need the file in a CSV format
Question by:gdenten
    LVL 26

    Accepted Solution

    xlsFile.Application.ActiveWorkBook.SaveAs Filename:="c:\test.csv", FileFormat:=6

    Author Comment

    I changed the code and it worked.  I guess a follow-up question mostly for my understanding is why didn't xlCSV work.  I copied that code from the MACRO I generated in EXCEL.
    LVL 26

    Expert Comment

    If you run from VB, then you may not see it if you don't have Excel reference

    Press F2 from ide and to see whether you see it

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now