+ Reply to Thread
Results 1 to 4 of 4

GetSaveAsFilename - change file type, runtime error 1004

  1. #1
    Forum Contributor
    Join Date
    10-22-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    162

    GetSaveAsFilename - change file type, runtime error 1004

    Hello,

    I have a workbook that I'm trying to suggest a filename for when the user selects Save As. That's all I wanted to achieve but it's getting increasing complicated and now I have a runtime error I can't seem to find a way around.

    I want to allow the user the ability to select a .xlsx file type if they wish, which all works fine until it hits ThisWorkbook.SaveAs when I get a runtime 1004 error:

    Please Login or Register  to view this content.
    Originally I didn't have the FileFormat specified and it gave me a runtime 1004 error with text stating that it couldn't be saved as this file type.

    sFullName contains: \\...\Profile\Desktop\SaveAs TestMacro\2017-10-10RMSelfTestResultsSR.xlsx ("..." are to shorten the string for visibility in this posting, the full file path is actually correct)
    sExt contains: .xlsx

    The code works fine if saving as an .xlsm file.

    Anyone have any ideas what's wrong with this - or an alternative method of pre-populating the Save As filename?

    Any assistance appreciated

    Thanks, TC

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: GetSaveAsFilename - change file type, runtime error 1004

    ".xlsx" is not a valid value for the FileFormat argument. The correct value for that would be 51- the value of the xlOpenXMLWorkbook constant.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    10-22-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    162

    Re: GetSaveAsFilename - change file type, runtime error 1004

    Ah, I see. That simple!

    I've modified the code again, but it just feels really clunky - it works fine. I've adapted someone else code to start with so perhaps that's why it doesn't quite feel right. The structure feels more unwieldy that it need be:

    Please Login or Register  to view this content.
    Am I missing something, or worrying about nothing?

  4. #4
    Forum Contributor
    Join Date
    10-22-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    162

    Re: GetSaveAsFilename - change file type, runtime error 1004

    Marking post as solved because my initial problem has been - but would still appreciate any input regarding streamlining structure.

+ 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. Runtime Error 1004 - File Format Invalid
    By NEU2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2017, 02:32 PM
  2. [SOLVED] runtime error 1004 Getsaveasfilename of object application failed
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2017, 09:57 AM
  3. [SOLVED] Runtime Error 1004 cant find the file, but it knows it's name
    By PJC2013 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-25-2016, 06:43 AM
  4. Runtime error 1004 when trying to save file via VBA
    By avh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2015, 03:20 AM
  5. [SOLVED] Receiving Runtime Error 1004 -Cannot Access file
    By Dean Staples in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2013, 09:27 PM
  6. Runtime Error 1004 : file could not be accessed
    By deepyogi in forum Excel General
    Replies: 1
    Last Post: 07-24-2009, 11:54 AM
  7. File Name Causes Runtime Error 1004
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2005, 10:55 AM

Tags for this Thread

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