Checking if any 'protected view' workbooks are open

toastie

New Member
Joined
Apr 4, 2013
Messages
1
Hello all,

I have a workbook which strips out most things (toolbar, status bar, formula bar, ply, disables cut/copy/paste).

This occasionally creates a problem when somebody is already working on another workbook and wonders why it suddenly looks strange :confused:

My simple workaround for this is to check (on Workbook_Open) if there are any other workbooks already open, and if so prevent this workbook opening:

Code:
(start of Workbook_Open)
    Dim wbsopen
    
    wbsopen = Application.Workbooks.Count
    
    If wbsopen > 1 Then
        MsgBox "There are other Excel spreadsheets open at the moment. You must close all other Excel spreadsheets, then try opening this program again"
        ThisWorkbook.Close
        Exit Sub
    End If

This works great, except that it doesn't detect a workbook which is open but in 'protected view'.
I don't want to disable protected view, so is there a way to modify my code to include checking for any workbooks open in protected view?

I'm guessing this is to do with how protected view prevents code from being run...

I have another related problem too, but I'll cross this bridge first!

Thanks in advance for any help
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top