Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2021, 07:57 AM
JingleBelle JingleBelle is offline Opening PW-protected Files (w/Same PW) and Resaving Without PW Windows 10 Opening PW-protected Files (w/Same PW) and Resaving Without PW Office 2016
Novice
Opening PW-protected Files (w/Same PW) and Resaving Without PW
 
Join Date: Nov 2020
Posts: 18
JingleBelle is on a distinguished road
Default Opening PW-protected Files (w/Same PW) and Resaving Without PW

Good morning!



Using code from this forum (Macropod's), I am trying to remove (open) passwords from all files within a folder. All files share the same password. I'd like to remove the password and resave the files. Ideally, I'd like to re-save them in a new folder; however, I would be ecstatic if I can get them to save without password.

I've spent several hours over a couple of days trying to figure this out on my own, but I have been unsuccessful. Following is my latest failed attempt.

Thank you in advance for reviewing the code, and I appreciate any suggestions.

Code:
Sub DeleteAllOpenPW()

Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
Dim StrPassword As String

Application.ScreenUpdating = False
strDocNm = ActiveDocument.FullName: strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.docx", vbNormal)
StrPassword = InputBox("What is the password to delete?", "Password")
While strFile <> ""
  If strFolder & "\" & strFile <> strDocNm Then
    Set wdDoc = Documents.Open(Filename:=strFolder & "\" & strFile, PasswordDocument:=StrPassword, AddToRecentFiles:=False, Visible:=False)
      With wdDoc
         wdDoc.SaveAs strFolder & strFile, Password:=""
         .Close SaveChanges:=True
     End With
   End If
   strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub


Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Reply With Quote
  #2  
Old 06-22-2021, 10:58 PM
gmayor's Avatar
gmayor gmayor is offline Opening PW-protected Files (w/Same PW) and Resaving Without PW Windows 10 Opening PW-protected Files (w/Same PW) and Resaving Without PW Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Seehttps://www.gmayor.com/document_batch_processes.htm You will need the password to open the files and the readonly password (if any).
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 06-23-2021, 05:10 AM
JingleBelle JingleBelle is offline Opening PW-protected Files (w/Same PW) and Resaving Without PW Windows 10 Opening PW-protected Files (w/Same PW) and Resaving Without PW Office 2016
Novice
Opening PW-protected Files (w/Same PW) and Resaving Without PW
 
Join Date: Nov 2020
Posts: 18
JingleBelle is on a distinguished road
Default

Hey, Graham.

Good morning!

Thank you for the link to the add-in; unfortunately, I am on a company network, and the security protocols will not allow me to download or install any add-ins. In fact, I could not get to the site. I had to email it to my personal account to access it. Even if I download it there, I'm still unable to install it at my work.

Thank you, again, and I appreciate your taking an interest in my post for help.

-JB

Last edited by JingleBelle; 06-23-2021 at 05:12 AM. Reason: Minor correction.
Reply With Quote
Reply

Tags
delete known password, resave with no password



Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening PW-protected Files (w/Same PW) and Resaving Without PW Word crashes when opening password protected doc PaulHoll Word 22 10-19-2021 06:13 AM
Word file says 'Opening in Protected View' but not opening. Yakbird Word 2 07-08-2019 10:55 AM
Opening PW-protected Files (w/Same PW) and Resaving Without PW File Opening in Protected View Love2All Excel 3 01-17-2014 03:23 AM
Opening PW-protected Files (w/Same PW) and Resaving Without PW Opening Word /Excel reinstalls files, loses recent files adj1 Office 3 05-10-2013 12:27 AM
Password Protected Files gurp99 Word 0 08-17-2010 03:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft