Class ProtectedViewWindows (Excel VBA)

A collection of the ProtectedViewWindow objects that represent all the Protected View windows that are currently open in the application. To use a ProtectedViewWindows class variable it first needs to be instantiated, for example


Dim pvws as ProtectedViewWindows
Set pvws = Application.ProtectedViewWindows

For Each

Here is an example of processing the ProtectedViewWindows items in a collection.


Dim pvw As ProtectedViewWindow
For Each pvw In Application.ProtectedViewWindows
	
Next pvw

Count

Returns a Long value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = Application.ProtectedViewWindows.Count

Item

Returns a single object from a collection.

Item (Index)

Index: The name or index number of the object.


Dim pvwItem As ProtectedViewWindow
Set pvwItem = Application.ProtectedViewWindows(Index:=1)

Open

Opens the specified workbook in a new Protected View window.

Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

Open (Filename, Password, AddToMru, RepairMode)


ProtectedViewWindows.Open FileName:="C:\MyFiles\MyWorkbook.xls" 

Arguments

The following argument is required

Filename (String) - The name of the workbook (paths are accepted).

Optional arguments

The following arguments are optional

Password (String) - The password for opening the workbook.

AddToMru (Boolean) - True to add the file name to the list of recently used files on the Recent tab of the Backstage view.

RepairMode (Boolean) - True to repair the workbook to prevent file corruption.