+ Reply to Thread
Results 1 to 3 of 3

Getting error when saving a worksheet to a new workbook in a macro

  1. #1
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    313

    Getting error when saving a worksheet to a new workbook in a macro

    I am trying to save a worksheet from one workbook as a new workbook with a variable name. I've found the code works fine if I use a static name. For example in this macro:

    Please Login or Register  to view this content.
    The static workbook "xxxxxxxxxx_date_yyyy.xlsm" is saved in my directory however in my macro (StoreMatchSheets) in workbook (MatchSheets.xlsm) I get an error box.

    The code in the macro is:
    Please Login or Register  to view this content.
    I get the following popup box:

    The following feature cannot be saved in macro free workbooks:

    . VB Project

    To save a file with these features, click no, and the choose a macro enabled file type in the file type list

    To continue saving a macro free workbook, click yes.

    When I click no the result is error msg: Runtime error 1004 VB projects & slm sheets cannot be saved in a macro free workbook

    When I click yes the result is error msg: Runtime error 1004. This extension cannot be used with the selected file type. Change the file extension in the file name test box or select a different file type by changing the save as type.

    Note: I have tried changing file name extension to xlsx, xlsm and xlsb.


    I'm attaching the main workbook and three other workbooks which may have links from formulas in the main book (MatchSheets.xlsm).

    The variable name in macro (StoreMatchSheets) looks correct to me when I hover the cursor over the variable strings.


    Thanks for any advice.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-07-2013
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    601

    Re: Getting error when saving a worksheet to a new workbook in a macro

    My initial guess is that you need to change FileFormat:=xlOpenXMLWorkbook to FileFormat:=xlOpenXMLWorkbookMacroEnabled. Unfortunately, I can't test VBA right now.
    If someone helped achieve your solution, consider clicking "* Add Reputation" on their post.

    If your question has been answered, mark the thread as [SOLVED] using the Thread Tools menu at the top of the thread.

  3. #3
    Forum Contributor
    Join Date
    07-20-2015
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2016
    Posts
    313

    Re: Getting error when saving a worksheet to a new workbook in a macro

    Thanks so much Melvosh - that fixed the problem immediately.

+ 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. Error when saving a workbook
    By zookeepertx in forum Excel General
    Replies: 7
    Last Post: 07-06-2018, 09:37 AM
  2. Worksheet Macro Error When Running Workbook Macro
    By Phil Hageman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2016, 07:07 AM
  3. Creating a new workbook, copying sheets & saving workbook - Subscript error
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2014, 09:04 AM
  4. Error 9 when saving workbook
    By 06nenglish in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-06-2013, 10:47 AM
  5. [SOLVED] Saving worksheet using a macro. Problem is that it is saving more rows than it needs to
    By Kammphoto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2013, 10:09 AM
  6. Renaming Active.Workbook and saving it without saving Macro
    By Djwill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-04-2012, 03:09 AM
  7. Saving autoloading same workbook in macro 1004 error
    By Cluv in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-03-2011, 08:10 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