PDA

View Full Version : Excel VB "Unprotect" workbook statement



Techgirl7
03-27-2018, 07:42 AM
I have a current macro that works...opens files, updates, saves, then close. See below.

Sub TestUpdate()
Workbooks.Open Filename: = V:\user folder\filename.xls, updatelink:=3
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

We are having issues with the Protected view prompt, enable editing. This stops our macros, and we run through about 25 files with this current macro. How do I add the VB "Unprotect" statement that will turn this off on every file when it is opened, before the update begins?

Thank you for your help !!

SamT
03-27-2018, 08:34 AM
Try this

Sub UnProtectingWorkbooks()
Const Passwurd As String = "???"

Workbooks.Open Filename: = "V:\user folder\filename.xls", updatelink:=0
With ActiveWorkbook
.UnProtect Passwurd 'If PAssword needed
.updatelinks
.Save
.Protect Passwurd 'If PAssword needed
.Close
End With
End Sub

Techgirl7
03-27-2018, 11:37 AM
I keep getting a run-time error 424, object required.

Techgirl7
03-27-2018, 11:40 AM
Also, this is not password protected, but files open in protected view, enable editing.

Paul_Hossler
03-27-2018, 12:25 PM
TRY this to see if it works for you (Excel 2016)

Excel Options

Trust Center

Trust Center Settings

Protected View

and uncheck the three boxes

21936