svendiamond
Well-known Member
- Joined
- Jun 13, 2014
- Messages
- 1,504
- Office Version
- 365
- Platform
- Windows
I have the following code which is supposed to loop through all open workbooks which are currently in "Protected View" (the yellow bar where you need to click "Edit" to be able to use the workbook) and it only loops through one or two, then stops and I don't know why.
Any idea why this loop only gets some of the workbooks, some of the time? I always have six workbooks that I open from email attachments that automatically open in Protected View. And when I run this macro, it will go through two, maybe three, but it leaves the other three in Protected View. Any help is appreciated. Thanks.
Code:
'protected view fix
Dim bk As Workbook, w As Long, wCount As Long
wCount = Application.ProtectedViewWindows.Count
On Error Resume Next
If wCount > 0 Then
For w = 1 To wCount
Application.ProtectedViewWindows(w).Activate
Application.ProtectedViewWindows(w).Edit
Next w
End If
On Error GoTo 0
Any idea why this loop only gets some of the workbooks, some of the time? I always have six workbooks that I open from email attachments that automatically open in Protected View. And when I run this macro, it will go through two, maybe three, but it leaves the other three in Protected View. Any help is appreciated. Thanks.