Document.WindowSize Event

Occurs when the document window is resized or moved.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)


Event WindowSize As WindowEventHandler
event WindowEventHandler WindowSize


The following code example creates a handler for the WindowSize event. The event handler displays in the window caption the number of times that the window has been resized. This example is for an application-level add-in.

Private resizeCount As Integer = 0
Private Sub DocumentWindowSize()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.WindowSize, AddressOf ThisDocument_WindowSize
End Sub

Private Sub ThisDocument_WindowSize(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.WindowEventArgs)
    resizeCount += 1
    e.Window.Caption = "Window resized " & resizeCount.ToString() & " times."
End Sub
int resizeCount = 0;
private void DocumentWindowSize()
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.WindowSize +=
        new Microsoft.Office.Tools.Word.WindowEventHandler(

void ThisDocument_WindowSize(object sender,
    Microsoft.Office.Tools.Word.WindowEventArgs e)
    e.Window.Caption = "Window resized " +
        resizeCount.ToString() + " times.";

.NET Framework Security

See Also


Document Interface

Microsoft.Office.Tools.Word Namespace