+ Reply to Thread
Results 1 to 6 of 6

Saving as .csv with VBA different than manual save as .csv?

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    bay area, ca
    MS-Off Ver
    Excel 2003
    Posts
    6

    Saving as .csv with VBA different than manual save as .csv?

    I am trying to save a worksheet into a different workbook as a .csv. When i open this saved file with notepad it looks corrupted (lots of squares and symbols but not my actual worksheet data). However, when I manually copy and paste it into a different workbook and saveas a csv then reopen in notepad everything looks as it should (my data separated by commas). Here is what I have been using.. am I missing something?

    myFile1 = Application.GetSaveAsFilename("C:...\", "CSV comma delimited (*.csv), *.xls", , "Select location to save.")

    myFile1 = Application.GetSaveAsFilename("C:...\", "CSV comma delimited (*.csv), *.csv", , "Select location to save.")

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Saving as .csv with VBA different than manual save as .csv?

    Hello curiouscat8,

    The file extension determines which program will open the file. If you have an Excel file saved in CSV format, but with an XLS extension, Excel will convert the file from XLS format to CSV format. If you have saved the file as a CSV extension then the system will save the file as a Comma Separated Value text file.

    Opening the XLS file saved as CSV format in Notepad will display the XLS file contents, hence all the weird characters. Opening a file with a CSV extension in Notepad will display correctly as text separated by commas.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-03-2013
    Location
    bay area, ca
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Saving as .csv with VBA different than manual save as .csv?

    Thanks for replying Leith. Is there a way I can convert it to mimic the manual SaveAs where it converts it to a CSV format but still have the file name and location manually entered by the user?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Saving as .csv with VBA different than manual save as .csv?

    Hello curiouscat8,

    Give me an example of what you want to do.

  5. #5
    Registered User
    Join Date
    04-03-2013
    Location
    bay area, ca
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Saving as .csv with VBA different than manual save as .csv?

    Hi Leith,

    I believe I might have just found my mistake. I didn't have a fileformat selected in my SaveAs code so I think this was screwing it up by defaulting to an excel format. Sheesh! Nonetheless, thanks for replying!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Saving as .csv with VBA different than manual save as .csv?

    Hello curiouscat8,

    In case that doesn't work, let me know.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1