#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
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. |
Tags |
delete known password, resave with no password |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
File Opening in Protected View | Love2All | Excel | 3 | 01-17-2014 03:23 AM |
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 |