+ Reply to Thread
Results 1 to 9 of 9

How do I force saving as *.xlsm without using .SaveAs

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: How do I force saving as *.xlsm without using .SaveAs

    Quote Originally Posted by AlphaFrog View Post
    I think that's a permanent (beyond the current session) change. You could store their current setting, change to macroenabled, then restore the original when closing the workbook.

    'Standard code module declare a public variable
    Public OrigSaveFormat As Long

    'Before they save
    OrigSaveFormat = Application.DefaultSaveFormat
    Application.DefaultSaveFormat = xlOpenXMLWorkbookMacroEnabled


    'Before workbook close
    Application.DefaultSaveFormat = OrigSaveFormat
    Having just tested it with our set up here, it seems that after the setting has been changed the new workbook still "wants to be" a .xlsx file. However, if I shut down Excel and relaunch it, then run the macro again without instructing another change to the default save as file type, then the new workbook wants to be a .xlsm file.

    It seems as though the setting is only read by Excel at Excel startup time. Would that be right? I suppose this behaviour could also be something to do with that TRIM add-in.

    Like I say though, it doesn't matter for my purposes as a permanent change to this setting is fine so thanks to you I can now test for this and display a short message asking the user to shutdown and relaunch Excel if the setting isn't correct when the workbook is opened which should naturally only appear once (or if the user changes the setting manually from .xlsm at any point)
    Please click *Add Reputation if I've helped

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How do I force saving as *.xlsm without using .SaveAs

    Quote Originally Posted by kadeo View Post
    It seems as though the setting is only read by Excel at Excel startup time. Would that be right? I suppose this behaviour could also be something to do with that TRIM add-in.
    I really don't know. I'll take your word for it if you've tested it.

    What if you just saved the workbook as a temporary .xlsm file? Then later delete the temp file after the workbook is closed or SavedAs another file.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: How do I force saving as *.xlsm without using .SaveAs

    Quote Originally Posted by AlphaFrog View Post
    ...What if you just saved the workbook as a temporary .xlsm file? Then later delete the temp file after the workbook is closed or SavedAs another file.
    Yeah, I had thought of that. In fact that's how I get around another issue with the TRIM add-on that doesn't allow me to specify a name for saving a new file as. The only way you can name a new file being saved to TRIM is to do it in the TRIM save dialog so my macros save to a temp file so that when I then save that to TRIM its no longer a new file and TRIM just uses the name the file already has. Thats OK for me cos I know what's happening and know to hit SaveAs to get it into TRIM. Others though are used to just hitting Save on a new document and as per normal Excel operation, if the file hasn't been previously saved, the Save function operates as SaveAs. So doing it this way risks the user just saving to the temporary file location instead of into TRIM. Using Workbook_BeforeSave to alter this brings me right back to original issue of inserting code into a new workbook. It would be so much easier if I could just get my hands on whatever API the TRIM add-in uses but it has eluded my efforts thus far.

+ 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. Replies: 0
    Last Post: 05-20-2014, 12:01 PM
  2. [SOLVED] Force .xlsm to save as .xlsx or .xls in VBA
    By JayRab in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2014, 03:13 PM
  3. SaveAs alert when change xlsm to xlsx
    By Altair in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2013, 05:50 AM
  4. [SOLVED] Dialog saveas xlsm filter
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2013, 01:27 PM
  5. [SOLVED] Force Save as .xlsm filetype
    By DJvdW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2012, 09:22 AM
  6. [SOLVED] ActiveWorkbook.SaveAs function needs to save as .xlsb instead of .xlsm
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-21-2012, 10:38 AM
  7. Force overwrite when using SaveAs
    By shawnpgorman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2007, 11:17 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