+ Reply to Thread
Results 1 to 6 of 6

save file no dialog

  1. #1
    Registered User
    Join Date
    03-16-2020
    Location
    uk
    MS-Off Ver
    2016
    Posts
    33

    save file no dialog

    Hi all,

    I'm trying to save the current template as a new file the code I'm using is

    Please Login or Register  to view this content.
    it opens a save file dialog with all the details in but the user could edit the name or location so i want to stop the dialog and just save it

    kind regards tim

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: save file no dialog

    Templates have to be saved with the SaveAs method to avoid destroying the template. If you know the name you want to use for the file and the type of file format you want then you can avoid the GetSaveAsFileName dialoig box with direct saveas statement like this example. Assume the name to be used is mydata and it is to be saved as a standard Excel workbook.
    Please Login or Register  to view this content.
    this will save the file to your default directory with the file name myData.xlsx. If you want to save the file in a different directory than your default directory then that file path will need to be entered in front of the file name like this example.
    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    03-16-2020
    Location
    uk
    MS-Off Ver
    2016
    Posts
    33

    Re: save file no dialog

    hi thanks for the quick reply my workbook contains marcos so but I get an error saying this extension cannot be used with the selected file type, I doesent seam to matter if I edit it to .xlsm either

    kind regards tim

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: save file no dialog

    You may be able to suppress the system dialog boxes with this line

    Application.EnableEvents = False

    but remember to reset the environment with

    Application.EnableEvents = True

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,419

    Re: save file no dialog

    If you are using the .SaveAs to save no .xlsx file types you will need to include the FileFormat argument to specify the file type

    https://docs.microsoft.com/en-us/off...orkbook.saveas

    if you template contains code then for a template it would be .xltm xlOpenXMLTemplateMacroEnabled
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: save file no dialog

    Quote Originally Posted by tim_p View Post
    hi thanks for the quick reply my workbook contains marcos so but I get an error saying this extension cannot be used with the selected file type, I doesent seam to matter if I edit it to .xlsm either

    kind regards tim
    Like @Andy Pope said, you would need to include the FileFormat type when saving as a different format than the original. This link might help:
    https://docs.microsoft.com/en-us/off...orkbook.saveas
    Then for the format types:
    https://docs.microsoft.com/en-us/off...l.XlFileFormat
    Last edited by JLGWhiz; 06-22-2020 at 08:51 AM.

+ 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. Populate file path and file name in save as dialog box using text in worksheet
    By runnerD2016 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-19-2016, 05:04 PM
  2. [SOLVED] File Save As Dialog with VBA
    By Pho6 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2014, 01:21 PM
  3. How to Save A File Using Dialog Box?
    By mitchivous in forum Excel General
    Replies: 0
    Last Post: 07-14-2013, 10:24 PM
  4. [SOLVED] automatic name in 'save as dialog box' ok, but does not actually save the file?!
    By Pluym in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2012, 10:05 AM
  5. save file dialog box
    By Directlinq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2009, 04:43 PM
  6. How to set file Filter in Save dialog box
    By sreenath205 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2006, 08:53 AM
  7. [SOLVED] How do you disable save file dialog?
    By someone in forum Excel General
    Replies: 3
    Last Post: 02-12-2005, 08:06 PM

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