Class ProtectedViewWindows (Word VBA)

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


Dim pvws as ProtectedViewWindows
Set pvws = ProtectedViewWindows

For Each

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


Dim pvw As ProtectedViewWindow
For Each pvw In ProtectedViewWindows
	
Next pvw

Count

Returns a Long that represents the number of Protected View windows in the collection.


MsgBox ProtectedViewWindows.Count

Item

Returns an individual ProtectedViewWindows object in a collection.

Item (Index)

Index: The individual object to be returned.


Dim pvw As ProtectedViewWindow
Set pvw = ProtectedViewWindows(Index:=1)

Open

Opens the specified document 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, AddToRecentFiles, PasswordDocument, Visible, OpenAndRepair)


ProtectedViewWindows.Open FileName:="C:\MyFiles\MyDoc.doc" 

Arguments

The following argument is required

FileName (String) - The name of the document (paths are accepted).

Optional arguments

The following arguments are optional

AddToRecentFiles (Boolean) - True to add the file name to the list of recently used files at the bottom of the File menu.

PasswordDocument (String) - The password for opening the document.

Visible (Boolean) - True if the document is opened in a visible window. The default value is True.

OpenAndRepair (Boolean) - True to repair the document to prevent document corruption.