|
-
Feb 21st, 2008, 12:51 PM
#1
Thread Starter
Hyperactive Member
Problem with Password protected Word files
When my code encounters a password protected Word file in the "For Each" loop, it prompts the user for the password, then suddenly the hidden Word app becomes visible ( even though I stated "oWApp.ScreenUpdating = False" ) and the user is seeing the opening & closing of the rest of each document inside the For Each loop.
When I encounter a password protected file, I need to log the Word filepath and go on to the Next file, without exiting the loop. I'm having problems with this line: Set oWDoc = oWApp.Documents(abc)
When I place the problem line before the Open statement, I get "bad file name" .
Variable abc contains a full server and path, like: \\SERVER\User\My Documents\FileName.doc
When I place the problem line and the HasPassword test, after the Open statement, I get the original problem - a password prompt and the Word app becomes visible while still processing files.
Code:
Set oWApp = GetObject(, "Word.Application")
If ERR_APP_NOT_RUNNING Then
Set oWApp = CreateObject("Word.Application")
End If
oWApp.ScreenUpdating = False
For Each abc In colStoreWFiles
Set oWDoc = oWApp.Documents(abc) 'PROBLEM LINE
If oWDoc.HasPassword = True Then
Print #LOG, "message"
Else
Set oWDoc = oWApp.Documents.Open(abc, , False)
....etc....
End If
Any information is appreciated.
Last edited by CyberJar; Feb 21st, 2008 at 12:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|