Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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: 26
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
 

Tags
delete known password, resave with no password

Thread Tools
Display Modes


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 02:53 PM.


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