+ Reply to Thread
Results 1 to 8 of 8

VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    GB
    MS-Off Ver
    Excel 2003
    Posts
    3

    VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Hi,

    I need some code to help me with a template at work. When the user clicks the macro button the last action I need it to do:

    1. Open the 'Save As' dialogue box (at a pre-determined folder) so the user can set the file name to be saved.
    2. Change the 'Save As Type' to - CSV (Comma Delimited) (*csv)

    The only code i've got to work at the moment, does the above but without letting me choose my own filename, it just saves it current filename.

    Thanks in advance
    Dale
    Using Excel 2007

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Dale

    Use Application.GetOpenFilename and ChDir.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-24-2013
    Location
    GB
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Hi Norie,

    Thanks for your help. The code works and saves the file, but when i go to the chosen folder on the hard drive the file i saved isn't there.

    I had this issue before and wondered if it was to do with the file type in the code ie "CSV File"

    When you manually save the file and use the drop down option "CSV (Comma Delimited) (*csv)" the file saves and is in the folder.

    Is it possible to put in the code to select "CSV (Comma Delimited) (*csv)" as the file type?

    Hope that makes sense

    Thanks
    Dale

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Dale

    The code doesn't save the file, it only gets the name to use when saving it.

    You need further code to save the file, or another approach.

  5. #5
    Registered User
    Join Date
    01-24-2013
    Location
    GB
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Hi Norie,

    I don't need the code to actually save the file. The user will manually click save once they've chosen the filename, it's just there seems to be an issue with the file format in the code as the saved file doesn't appear in the file directory.

    Any ideas?
    Dale

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Dale

    What code are you using to save the file?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Clicking Save doesn't do it; that will just save the workbook.

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,888

    Re: VBA/Macro Code needed to open 'Save As' dialogue box and set the file type to CSV

    Perhaps this is what you are looking to do?

    http://www.datapigtechnologies.com/f...alogboxes.html
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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