共用方式為


DocumentBase.Windows Property

Gets a Windows collection that represents all windows for the document (for example, Sales.doc:1 and Sales.doc:2).

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

Syntax

'Declaration
Public ReadOnly Property Windows As Windows
public Windows Windows { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Windows
A Windows collection that represents all windows for the document.

Examples

The following code example creates two new windows for the document, and then uses the Windows property to tile all of the document windows from the top left of the screen. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentWindows()
    Dim window1 As Word.Window = Me.Windows.Add()
    Dim window2 As Word.Window = Me.Windows.Add()

    Dim top As Integer = 10
    Dim left As Integer = 10
    Dim window As Word.Window
    For Each window In Me.Windows
        window.Top = top
        window.Left = left
        top += 10
        left += 10
    Next window
End Sub
private void DocumentWindows()
{
    Word.Window window1 = this.Windows.Add(ref missing);
    Word.Window window2 = this.Windows.Add(ref missing);

    int top = 10;
    int left = 10;
    foreach (Word.Window window in this.Windows)
    {
        window.Top = top;
        window.Left = left;
        top += 10;
        left += 10;
    }
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace