Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking if a file is protected (Word 97 Sr2)

    I have a macro that will go through all documents in a filepath, open them, change settings, then close and save automatically.

    One of my problems is with password protected documents - where the File - SaveAs - Options - password to modify has been set. Word throws up a box asking for the password, and the macro is interrupted.
    I understand from other threads here that if you put in a 'dummy' password then an error is returned that can be trapped, and allow the macro to continue.
    However, for some reason this doesn't seem to work for me. The portion of my code runs as:
    Set oDoc = Documents.Open( _
    FileName:=strFilePath & strFileName, AddToRecentFiles:=False,
    PasswordDocument:="?#nonsense@$")
    (taken from the MVPS.org website - thanks)
    But Word seems to ignore the addtorecentfiles and the passworddocument portions of the documents.open command, and throws up the password box anyway.

    Any ideas?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Checking if a file is protected (Word 97 Sr2)

    Hey, I thought that was my idea. <img src=/S/wink.gif border=0 alt=wink width=15 height=15> I really cannot understand why this should fail, particularly if it worked for Chris G when he tested it in Word97. Sorry.

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checking if a file is protected (Word 97 Sr2)

    Thanks for that. I did read that thread, and should have acknowledged, but just copied the whole text from elsewhere.
    Worked out what the problem was, and it's the kind that makes you go Doh!. I hadn't noticed the 'WritePasswordDocument' part of the Documents.Open command. Some of the documents I was trying to update in a batch were Write protected, so sticking an unlikely password in here as well has the same affect as in the PasswordDocument, and the macro now works as intended.

Posting Permissions

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