Hello guys,
So i created a command button macro that locate a file with a specific name but it seems that if the file is in "protected view", the macro cannot locate the file...
If i enable editing, it does work... If i don't it can't locate the file
I feel like i tried everything
Application.ActiveProtectedViewWindow.Edit
or
If Application.ProtectedViewWindows.Count > 0 Then
Application.ActiveProtectedViewWindow.Edit
End If
or
Unprotect
See macro below... Let me know what you think, i always get MsgBox ("There is no file currently open.") if i don't click on EDIT
Thanks for your help
Sub TD_Click()
Dim UtilWb As Workbook, Wb As Workbook
For Each Wb In Application.Workbooks
If Wb.Name Like "Fake name*" Then
Set UtilWb = Wb
Exit For
End If
Next Wb
If UtilWb Is Nothing Then
MsgBox ("There is no file currently open.")
'Ends macro if there is no util file
End
End If
'UtilWb.ActiveProtectedViewWindow.Edit
'UtilWb.Unprotect Password:=""
UtilWb.Activate
'If Application.ProtectedViewWindows.Count > 0 Then
'Application.ActiveProtectedViewWindow.Edit
'End If
End Sub
So i created a command button macro that locate a file with a specific name but it seems that if the file is in "protected view", the macro cannot locate the file...
If i enable editing, it does work... If i don't it can't locate the file
I feel like i tried everything
Application.ActiveProtectedViewWindow.Edit
or
If Application.ProtectedViewWindows.Count > 0 Then
Application.ActiveProtectedViewWindow.Edit
End If
or
Unprotect
See macro below... Let me know what you think, i always get MsgBox ("There is no file currently open.") if i don't click on EDIT
Thanks for your help
Sub TD_Click()
Dim UtilWb As Workbook, Wb As Workbook
For Each Wb In Application.Workbooks
If Wb.Name Like "Fake name*" Then
Set UtilWb = Wb
Exit For
End If
Next Wb
If UtilWb Is Nothing Then
MsgBox ("There is no file currently open.")
'Ends macro if there is no util file
End
End If
'UtilWb.ActiveProtectedViewWindow.Edit
'UtilWb.Unprotect Password:=""
UtilWb.Activate
'If Application.ProtectedViewWindows.Count > 0 Then
'Application.ActiveProtectedViewWindow.Edit
'End If
End Sub