+ Reply to Thread
Results 1 to 4 of 4

Run Time error 424 copy form work sheet to make a new file

  1. #1
    Registered User
    Join Date
    02-10-2018
    Location
    toronto ontario
    MS-Off Ver
    office 2010
    Posts
    66

    Run Time error 424 copy form work sheet to make a new file

    Hi all
    I having a run time error in a, I call it a export command I am trying to copy a portion of a work sheet and open a file dialog box to save it as a new file
    Below is the code I have so far it errors at the ActiveWorkbook.SaveAs FileName.xlsm
    any Help please and thanks
    Please Login or Register  to view this content.

  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: Run Time error 424 copy form work sheet to make a new file

    I think all you need is
    Please Login or Register  to view this content.
    The workbook was opened as a .xlsm macro enabled workbook and the variable 'FileName' is for the same workbook name that was opened. The syntax is incorrect for the SaveAs statement as you have it.
    Please Login or Register  to view this content.
    But even that could give undesired results if FilName includes the full file path that was in the GetOpenFilename box. You need to know exactly what your variables contatin when you are using them like that.
    Last edited by JLGWhiz; 09-28-2019 at 06:56 PM.
    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
    02-10-2018
    Location
    toronto ontario
    MS-Off Ver
    office 2010
    Posts
    66

    Re: Run Time error 424 copy form work sheet to make a new file

    The save error has been solved but it will not let predefine a file name it saves as sheet1 even if I change the file name

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

    Re: Run Time error 424 copy form work sheet to make a new file

    The way the code in Post #1 is written is confusing because it appears that the variable 'FileName' is initialized with the file opened through the 'GetSaveAsFileName' dialog box. Then it goes on to attempt to do a 'SaveAs' using he same variable value for 'FileName'. That would automatically throw an error for an alert message for a duplicate file name. That was why I suggested just using the 'ActiveWorkbook.Save' method. If you want to use the 'SaveAs' method so you can change the file name then you need to use either 1) change the value of the variable 'FileName' to something other than what was taken from the dialog box or 2) just use a different name in the clear.
    1)
    Please Login or Register  to view this content.
    2)
    Please Login or Register  to view this content.
    Hope this is a little clearer on the issue.
    Regards, JLG

+ 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. Please make my time sheet easier to work out
    By KingJohn in forum Excel General
    Replies: 3
    Last Post: 02-05-2017, 12:27 AM
  2. [SOLVED] VBA to auto save data each time it's entered into a work sheet frm user form
    By MG3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2015, 11:01 AM
  3. Copy Data from a Form to a work sheet
    By larrysdime in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2015, 06:08 PM
  4. Macros stop to work when work sheet is protected. Run time error 1004
    By sellim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2012, 01:14 AM
  5. Replies: 6
    Last Post: 05-02-2012, 07:07 AM
  6. Run-time error 1004 - Cannot copy sheet to new file
    By mjcordeiro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2009, 09:20 AM
  7. [SOLVED] In EXCEL2000, How can I copy a file and make it usable in MS WORK
    By TampaDog in forum Excel General
    Replies: 1
    Last Post: 09-15-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