+ Reply to Thread
Results 1 to 9 of 9

Problems with saving via VBA

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Problems with saving via VBA

    So we have some sort of form in which a macro 'submits' it.
    Basically what it does is save the workbook as a non macro workbook in a different place.

    This works for all people just fine....except for 1.....
    For what I know he has the same excel and settings and all (full open for macro's).
    Still only he gets the :
    "Runtime Error 1004: method saveas of object _workbook failed"

    This is the code for saving:
    Please Login or Register  to view this content.
    Could it have to do with "FileFormat:=xlOpenXMLWorkbook"
    But why would it still work for all others??

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Problems with saving via VBA

    "Activeworkbook" is prone to causing error, depending on user action and set up etc.

    Try specifying workbook object, using name or some other method.

    If you can, post full code. Just looking at that snippet, only advise I can give is above.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Problems with saving via VBA

    Ok let me then share the full code:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Problems with saving via VBA

    So, the code is saving the workbook that houses the code? Then just replace "Activeworkbook" with "ThisWorkbook" and see what happens.

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Problems with saving via VBA

    Yes I guess.

    Its like this.
    With another macro I generate several workbooks that house the code like above.

    Then user needs to fill that workbook and press button submit.
    Macro writes a copy to a different place as a (normal) xlsx.
    So the xlsm becomes and xlsx and then the xlsm gets deleted in the other folder.

    I will replace it with ThisWorkbook.
    Unfortunately this process happens only once a week so I will need to get back to you if this will work.

    Maybe there are some more things I can try?
    Like declaring the workbook or something?

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Problems with saving via VBA

    You could declare workbook variable and set it as well. Though it's not necessary if the code is referring to the workbook that it's housed in.

  7. #7
    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: Problems with saving via VBA

    Have you verified that the user has the P drive mapped, and to the same location as everyone else? And also that he or she has permission to save to that folder?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Problems with saving via VBA

    If that was the case, it should give same error number but different message.

    Something in line of...
    "Microsoft Excel cannot access the file..."

  9. #9
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Problems with saving via VBA

    Yup those where the first things i checked.

    When it crashed I ended the macro and manually saved the file (under his user account naturally) to the placed it should go.
    No problems (first also thought he would not have access to that folder, but was not the case).

+ 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. Saving problems
    By jacusmc18 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-19-2016, 02:09 PM
  2. [SOLVED] Workbook_BeforeSave problems with saving
    By Steve@Rugby in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 03-11-2014, 04:12 AM
  3. Saving .csv into .txt problems
    By macedo in forum Excel General
    Replies: 2
    Last Post: 06-09-2012, 02:37 PM
  4. Problems saving an xls document
    By Vivienne1973 in forum Excel General
    Replies: 3
    Last Post: 04-30-2012, 09:51 AM
  5. Saving problems:existing file,
    By kgclub in forum Excel General
    Replies: 1
    Last Post: 03-09-2006, 06:10 PM
  6. [SOLVED] Problems with saving to Sharepoint
    By jon in forum Excel General
    Replies: 1
    Last Post: 01-09-2006, 05:45 PM
  7. Saving problems
    By Vamshee in forum Excel General
    Replies: 2
    Last Post: 03-14-2005, 03:06 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