Hello
I have a large number of docs (500+) that I need to move to our
company server. They are all encrypted with the same password, and I
know the password, so I don't need a cracker program, but I am looking
for a script or utility that will allow me to remove password
protection from all of these docs at once.
The thought of doing them all one by one is pretty unappealing.
Thanks!
chrs
Use this macro (see
http://www.gmayor.com/installing_macro.htm if needed):
Sub demo()
Dim oDoc As Document
Dim fName As String
Const pwd = "MyPaSsWoRd" ' to be changed
Const pathToOpen = "C:\temp\" ' to be changed
Const pathToSave = "C:\temp1\" ' to be changed
fName = Dir$(pathToOpen & "*.doc")
If fName = "" Then
MsgBox "No *.doc files in " & pathToOpen
End If
WordBasic.DisableAutoMacros 1 ' disable any AutoOpen
On Error GoTo FinalExit
While fName <> ""
Set oDoc = Documents.Open(FileName:=pathToOpen & fName, _
PasswordDocument:=pwd, AddToRecentFiles:=False)
oDoc.SaveAs FileName:=pathToSave & fName, Password:=""
oDoc.Close SaveChanges:=wdDoNotSaveChanges
fName = Dir$()
Wend
Exit Sub
FinalExit:
WordBasic.DisableAutoMacros 0 ' reenable
If Err.Number <> 0 Then
Select Case Err.Number
Case 5152:
MsgBox "Could not save " & pathToSave & fName
Case Else
MsgBox Err.Number & vbCr & Err.Description
End Select
End If
End Sub
You'll have to enter the real password and the paths to the folders for the
original and "de-passworded" files. The macro could probably use some more
error handling, but this may be sufficient. Note that it will stop as soon
as there's any error and not go on to any more files; after fixing the
problem, remove any files from the source folder that have already been
processed, and then restart the macro.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.