+ Reply to Thread
Results 1 to 9 of 9

Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook failed

  1. #1
    Registered User
    Join Date
    02-18-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook failed

    On Windows 7 desktop, getting a Run-time error 1004: Method 'SaveAs' of object_Workbook failed on an Excel macro that worked in XP. The highlighted code where it halts is:

    ActiveWorkbook.SaveAs Filename:=_
    "G:\Fixed Income\Credit Daily Reports\Short Duration\" & rptdate & "_ShortDurationSector.xlsx",_
    File Format:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", ReadOnlyRecommend:=_
    False, CreateBackup:=False

    Any ideas why this would not work in Windows 7?

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    4,991

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    Are the office versions different? Try replacing xlOpenXMLWorkbook with the number 51 does that help at all?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    02-18-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    Thanks, both are Office 2010.

  4. #4
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit
    Posts
    624

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    "G" is a big letter for a HardDisk, was there a mapped lan connection (server) when working on XP ?
    Last edited by rollis13; 02-18-2014 at 05:42 PM.

  5. #5
    Registered User
    Join Date
    02-18-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    Yes, it was working in XP using the G: drive reference. Do you think that we should use the \\servername\folder format?

  6. #6
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit
    Posts
    624

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    Yes, or recreate the reference.

  7. #7
    Registered User
    Join Date
    02-18-2014
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    So you suggest this instead?

    ActiveWorkbook.SaveAs Filename:=_
    "\\servername\folder\Fixed Income\Credit Daily Reports\Short Duration\" & rptdate & "_ShortDurationSector.xlsx",_
    File Format:=51, Password:="", WriteResPassword:="", ReadOnlyRecommend:=_
    False, CreateBackup:=False

  8. #8
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit
    Posts
    624

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    Sorry, unabled to test, no Excel and Lan at the moment, looks ok .

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    4,991

    Re: Works in XP but not Win 7: Run-time error 1004: Method 'SaveAs' of object_Workbook fai

    FileFormat is one word in VBA, your code has a space... also, usually a space before the _ character? Try this:

    Please Login or Register  to view this content.

+ 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. getting run time error 424 or 1004 when using Saveas method
    By Anchal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2013, 03:37 AM
  2. Run Time Error '1004': Method 'saveas' of object '_workbook' failed
    By vcuphysics in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-21-2012, 04:50 PM
  3. Error 1004: Pastespecial method of range class failed, macro works sometimes!
    By sam0287 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-19-2009, 09:12 PM
  4. Replies: 4
    Last Post: 05-04-2006, 08:00 AM
  5. error 1004 Method SaveAs of Workbook failed
    By Maury Markowitz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2005, 04:05 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