+ Reply to Thread
Results 1 to 16 of 16

VBA Run Time Error when saving workbook between Users....?

  1. #1
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Angry VBA Run Time Error when saving workbook between Users....?

    Hi,

    I created a workbook that up to this point has worked well thanks to this forum. The VBA look at a specific cell value and either emails the active worksheet as a PDF file or saves the entire workbook as a xlms file to a specific folder.

    As I mentioned it has worked great without any problems when i am testing it but when i sent it to one of the users to try it they received the "Run Time Error.

    They have access to the folder location.

    Any ideas on why it works when I use it versus when another user?

    Macro:
    Please Login or Register  to view this content.
    Last edited by JosephP; 12-28-2012 at 02:04 PM. Reason: add code tags

  2. #2
    Valued Forum Contributor smuzoen's Avatar
    Join Date
    10-28-2011
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003/2007/2010
    Posts
    610

    Re: VBA Run Time Error when saving workbook between Users....?

    Can you be more specific. On what line does the error occur? You can debug the code on a users machine and step through the code so you can identify which line generates the error. I am pretty sure it will be on the save line. Even though users can browse to the network location can they actually write to the location. Get a user to copy a file and try and paste it into the network location to ensure they do have write permissions
    Last edited by smuzoen; 12-27-2012 at 06:46 PM.
    Hope this helps.
    Anthony
    Pack my box with five dozen liquor jugs
    PS: Remember to mark your questions as Solved once you are satisfied. Please rate the answer(s) by selecting the Star in the lower left next to the Triangle. It is appreciated?

  3. #3
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Run Time Error when saving workbook between Users....?

    Thanks Smuzoen. Below is where the error occurs. I have tested with other users and it works just fine.

    sht.ExportAsFixedFormat Type:=xlTypePDF, FileName:=SaveFolder & DocName, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    True

    The Macro was changed to save as a PDF.

    Please Login or Register  to view this content.
    Last edited by JosephP; 12-28-2012 at 02:05 PM.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Run Time Error when saving workbook between Users....?

    does that user have the same version of office as all the others (and same service pack if using office 2007)?

    please note that I added code tags to your post as required by the forum rules. please learn to use them
    Last edited by JosephP; 12-28-2012 at 02:05 PM.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Run Time Error when saving workbook between Users....?

    Thanks JosephP. Quick question how do i add code tags.

    We are both using Microsoft office 10

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Run Time Error when saving workbook between Users....?

    click the forum rules link at the top of this page and read forum rule 3 for instructions

    what is the actual error message and number that the user receives?

  7. #7
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Run Time Error when saving workbook between Users....?

    The error is:

    Run-Time error '1004':

    Document not saved. The document may be open, or an error may have been encountered when saving.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA Run Time Error when saving workbook between Users....?

    does the code work if you change it to use a local folder that the user has full rights to?

  9. #9
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Run Time Error when saving workbook between Users....?

    No. I checked the folder rights and the user has full rights. The weird part is that other users can save just fine but only 2 cannot and receive the same error

  10. #10
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: VBA Run Time Error when saving workbook between Users....?

    I've ran into a similar problem before. It sounds like the user either doesn't have access to the drive, or since it's a shared drive, the file has already been saved and someone unknowingly has it open, therefore it can't overwrite the existing file that has the same name. Could be something else, but this was the problem for me. I fixed it by adding an IF statement to check if the file was already open

  11. #11
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Run Time Error when saving workbook between Users....?

    Thanks VBA FTW.

    You don't happen to have any suggestions on adding the If statement to the code below do you that you mention above to help avoid the run time error?

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: VBA Run Time Error when saving workbook between Users....?

    I'm sorry but I was mistaken, I didn't use an IF statement, I used "On Error GoTo" instead. See edited code below (untested). Keep in mind I do not know if your problem is exactly the same as the one I had, so I don't know if this will fix your issue or not, but it's worth a shot. May want to test it out in a copy workbook to play it safe.

    Quote Originally Posted by slu2383 View Post
    Thanks VBA FTW.

    You don't happen to have any suggestions on adding the If statement to the code below do you that you mention above to help avoid the run time error?

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: VBA Run Time Error when saving workbook between Users....?

    Quote Originally Posted by VBA FTW View Post
    I'm sorry but I was mistaken, I didn't use an IF statement, I used "On Error GoTo" instead. See edited code below (untested). Keep in mind I do not know if your problem is exactly the same as the one I had, so I don't know if this will fix your issue or not, but it's worth a shot. May want to test it out in a copy workbook to play it safe.
    Thinking about this a little more, the edited code above won't help you identify if the file is actually open, rather, if an error happens, it will popup the msgbox rather than the VBA debug screen. Sorry for the confusion slu2383. But it still sounds to me like someone has the file open therefore the macro can't overwrite it. You may need to figure out if this is the case internally in your office and if you find that is indeed the problem, we can then get into writing some code to get around this.

  14. #14
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: VBA Run Time Error when saving workbook between Users....?

    Also, if you find that someone DOES indeed already have the file open, you can set OpenAfterPublish to false which, like the name implies, doesn't open the PDF after saving. Unless you want the user to be able to preview the file they're saving.

  15. #15
    Registered User
    Join Date
    12-26-2012
    Location
    St. louis
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA Run Time Error when saving workbook between Users....?

    Thanks VBA FTW.

    We tried both scenarios. The run time error came back up when I switched the OpenAfterPublish to false. In the second test the message box did pop up but we checked and nobody has the file open.

    One of those weird mysteries I guess.

  16. #16
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: VBA Run Time Error when saving workbook between Users....?

    Hmmm...well there's got to be something causing this issue, I'll definitely be thinking about this one

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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