ViewMode Property (Page Object Model)

Microsoft FrontPage Visual Basic

ViewMode Property (Page Object Model)

Returns a Long that represents whether the page has been edited in Code view. A 1 indicates that the page has not been edited; a 2 indicates that the page has been edited.

expression.ViewMode

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

In previous versions of Microsoft FrontPage, it was impossible to run Microsoft Visual Basic for Applications (VBA) code that modified the HTML in a page — for example, adding elements or changing attributes — while viewing the HTML in FrontPage. Doing so displayed a "Permission Denied" error.

With Microsoft Office FrontPage 2003, you can now make changes to the HTML in a page by using VBA code while a page is displayed in the FrontPage Code view. However, the FrontPage Page Object model becomes unavailable when edits are made in Code view. Use the ViewMode property to determine if changes have been made to a Web page in Code view. If the ViewMode property returns a 2, use the parseCodeChanges method to reparse the page without having to change the view and to eliminate receiving the "Permission Denied" error.

Example

The following example reparses the code in the active document if the document has been changed in Code view.

    Sub ReparseCodeInPage()

    If ActiveDocument.ViewMode = 2 Then
        ActiveDocument.parseCodeChanges
    End If

End Sub