+ Reply to Thread
Results 1 to 5 of 5

Save As file extension in VBA code

  1. #1
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Save As file extension in VBA code

    I'm having a little problem with a 'save as' macro. I don't know who is going to use the spreadsheet I'm working on, so I'd like to add a button that lets users save as a new file with a different name, but which opens a dialogue box to let them choose where (because I don't know who will be using it, so I can't specify the file path).

    However, I would like to a) suggest what they call the file based on some information they entered in the spreadsheet, and b) specify that the spreadsheet be saved as a macro-enabled file, because I know that if I don't I'll be getting a hundred emails a day asking why such-and-such doesn't work on their spreadsheet all of a sudden.

    This is the code I have, I thought adding 'xlsm' to the file name would do it, but that doesn't work (although the rest of it does, it brings up a save as dialogue box with the correct suggested filename), and I tried adding a 'file format' argument, but I must be getting the syntax wrong.

    This is the code for my macro:

    Please Login or Register  to view this content.
    Please could someone point out what I'm doing wrong? Thank you.

  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: Save As file extension in VBA code

    How is the code not working?

    Where's the code to actually save the workbook?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Save As file extension in VBA code

    Quote Originally Posted by Norie View Post
    How is the code not working?

    Where's the code to actually save the workbook?
    Perhaps I'm under a misapprehension, the code opens a 'save as' dialogue box, but will this not actually save the file, and just return the string instead? What I want to do is call Excel's 'save as' function, with the suggested file name and file type pre-populated, but allow the user to decide where to save it.

  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: Save As file extension in VBA code

    Application.GetSaveAsFilename will return the filename and path the user selects/enters.

    You should have another variable to store that and then use that variable with the SaveAs method.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: Save As file extension in VBA code

    Hi bevc

    Give this a go....
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to open a list of spreadsheet and save them under file extension xlsx file
    By gdclyde in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2017, 07:16 PM
  2. How to Save Excel to your own desired file extension
    By king05 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2017, 04:39 AM
  3. [SOLVED] how to save a CSV file with extension
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2016, 12:40 PM
  4. [SOLVED] Save Column as TXT file with .NC Extension
    By Tellm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2014, 03:26 PM
  5. How to save file with correct file extension, .xls or .xlsx?
    By Alexb77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2014, 12:52 PM
  6. How To Save Macro File Not Using .XLSM Extension
    By crouching_tiger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2014, 07:37 AM
  7. [SOLVED] Additional file with no extension created during File Save As proc
    By Peter Rooney in forum Excel General
    Replies: 2
    Last Post: 08-11-2005, 10:05 AM

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