Consulting

Results 1 to 5 of 5

Thread: Getting "file permission error" #5487

  1. #1
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location

    Getting "file permission error" #5487

    I have Word templates that are based on existing templates--I just added some macros and modified others.

    These templates are stored on two different servers--one in India and one in Canada. The templates are working fine in India, but when they are run in Canada, there is a sporadic 5487 error. The macros save the .doc file to a specific folder after it is initially created and then resaves the file at various points. The macros are stopping on a line of code that is simply trying to resave the file.

    [vba]ActiveDocument.Save[/vba]

    Does anyone have any ideas on why this is happening or what I could do to fix it? I'm at a total loss!

  2. #2
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Not to be snarky, but I would guess it is exactly what the error is giving you... whoemver is running the code doesn't necessarily have the file permissions to be able to save the document to the particular location.

    It is possible to have file permissions set up (not common, but possible) which allow a user to create a file, but not modify a file... so you could very well be saving the file initially, but unable to modify (resave) the same file.

    There are a lot of possibilities, but almost none of them are in the realm of vba troubleshooting.

  3. #3
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Actually, they do have the correct access. The first part of the macro does the initial save and the resave comes at the end. In some cases, they get the error at the end when it tries to resave. In other cases, it does the resave just fine and when they run a second macro on the file, it bombs when that tries to resave.

    It doesn't happen every time. Today I had someone test the file several times for me. It worked for them 3 times just fine and then gave them this error on the 4th time, then worked fine the next 6 times. Same user... same template... same machine...

    I don't have a clue how to resolve.

  4. #4
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Sorry Cheryl, but you'd have to post a lot more info for anyone (even Microsoft) to be able to give you any hint as to why you intermittently can't save a document to a specific location in your particular environment.

    I highly doubt it has anything to do with VBA's ActiveDocument.Save command (even if you had some code which hid the activedocument, so that there was no active document, you wouldn't get a file permissions error, you'd get an object not found error).

    I would suggest doing error trapping around the offending line of code, providing the user with the option to try saving again or continuing on with the code and a suggestion to try a manual save. For example:
    [vba]
    Sub ActiveDocumentSaveTest()
    Dim sErrMessage As String
    'all of your previous code

    On Error GoTo l_err
    ActiveDocument.Save

    'reset to your other error trapping, or no error trapping (which is 0)
    On Error GoTo 0
    'the rest of your code
    l_exit:
    Exit Sub
    l_err:
    sErrMessage = "Unable to Save the document, do you wish to try again?"
    Select Case MsgBox(sErrMessage, vbYesNo, "Wierd Error...")
    Case vbYes
    Resume
    Case vbNo
    MsgBox "Please manually save your document at the first opportunity.", vbInformation, "Please save..."
    Resume Next
    End Select
    End Sub
    [/vba]
    At the very least, you don't want to present the end-user with a microsoft debug window (which can cause other issues with variables falling out of scope, etc).

    From there, you could try logging the error manually to a txt file in some other location in order to get more datapoints as to why a network resource would be intermittently unavailable (getting date/time stamps when an ActiveDocument.Save failed, and trying to coordinate them with event logs, server logs, etc).

    Unless you have code to post that someone can review... simply having an intermittent problem with ActiveDocument.Save is pretty tough to help with.

  5. #5
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    This worked! I setup this error handling in the template and it just reruns that line of code--it works fine the second time--and it continues on to the end.

    Thank you so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •