Propriedade DocumentBase.Lists

Obtém uma coleção de Lists que contém todas as listas formatados no documento.

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

Sintaxe

'Declaração
Public ReadOnly Property Lists As Lists
public Lists Lists { get; }

Valor de propriedade

Tipo: Microsoft.Office.Interop.Word.Lists
Uma coleção de Lists que contém todas as listas formatados no documento.

Exemplos

O exemplo de código a seguir adiciona texto aos primeiros dois parágrafos, aplica um modelo de lista os parágrafos, e então exibe uma mensagem que mostra o número de listas no documento.Para usar este exemplo, ele execução da classe de ThisDocument em um projeto de um documento nível.

Private Sub DocumentLists()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphAfter()

    Me.Paragraphs(1).Range.Text = "This is the first paragraph."
    Me.Paragraphs(2).Range.Text = "This is the second paragraph."

    Dim Start As Object = Me.Paragraphs(1).Range.Start
    Dim [End] As Object = Me.Paragraphs(2).Range.End
    Dim myRange As Word.Range = Me.Range(Start, [End])
    Dim index As Object = 1

    Dim myTemplate As Word.ListTemplate = Application.ListGalleries( _
        Microsoft.Office.Interop.Word.WdListGalleryType.wdNumberGallery). _
        ListTemplates.Item(index)

    myRange.ListFormat.ApplyListTemplate(myTemplate)

    MessageBox.Show("Total lists in document: " & Me.Lists.Count.ToString())
End Sub 
private void DocumentLists()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphAfter();


    this.Paragraphs[1].Range.Text = "This is the first paragraph.";
    this.Paragraphs[2].Range.Text = "This is the second paragraph.";

    object Start = this.Paragraphs[1].Range.Start;
    object End = this.Paragraphs[2].Range.End;
    Word.Range myRange = this.Range(ref Start,
        ref End);
    object index = 1;

    Word.ListTemplate myTemplate = Application.ListGalleries[Microsoft.Office.Interop.Word.WdListGalleryType.wdNumberGallery].ListTemplates.get_Item(ref index);

    myRange.ListFormat.ApplyListTemplate(myTemplate, 
        ref missing, ref missing, ref missing);

    MessageBox.Show ("Total lists in document: " +
        this.Lists.Count.ToString());

}

Segurança do .NET Framework

Consulte também

Referência

DocumentBase Classe

Namespace Microsoft.Office.Tools.Word