Condividi tramite


Bookmark.ConvertToTable Method

Converts text within a Bookmark control to a table.

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

Syntax

'Declaration
Function ConvertToTable ( _
    ByRef Separator As Object, _
    ByRef NumRows As Object, _
    ByRef NumColumns As Object, _
    ByRef InitialColumnWidth As Object, _
    ByRef Format As Object, _
    ByRef ApplyBorders As Object, _
    ByRef ApplyShading As Object, _
    ByRef ApplyFont As Object, _
    ByRef ApplyColor As Object, _
    ByRef ApplyHeadingRows As Object, _
    ByRef ApplyLastRow As Object, _
    ByRef ApplyFirstColumn As Object, _
    ByRef ApplyLastColumn As Object, _
    ByRef AutoFit As Object, _
    ByRef AutoFitBehavior As Object, _
    ByRef DefaultTableBehavior As Object _
) As Table
Table ConvertToTable(
    ref Object Separator,
    ref Object NumRows,
    ref Object NumColumns,
    ref Object InitialColumnWidth,
    ref Object Format,
    ref Object ApplyBorders,
    ref Object ApplyShading,
    ref Object ApplyFont,
    ref Object ApplyColor,
    ref Object ApplyHeadingRows,
    ref Object ApplyLastRow,
    ref Object ApplyFirstColumn,
    ref Object ApplyLastColumn,
    ref Object AutoFit,
    ref Object AutoFitBehavior,
    ref Object DefaultTableBehavior
)

Parameters

  • NumRows
    Type: System.Object%

    The number of rows in the table. If this argument is omitted, Microsoft Office Word sets the number of rows, based on the contents of the Bookmark control.

  • NumColumns
    Type: System.Object%

    The number of columns in the table. If this argument is omitted, Word sets the number of columns, based on the contents of the Bookmark control.

  • InitialColumnWidth
    Type: System.Object%

    The initial width of each column, in points. If this argument is omitted, Word calculates and adjusts the column width so that the table stretches from margin to margin.

  • Format
    Type: System.Object%

    Specifies one of the predefined formats listed in the Table AutoFormat dialog box. Can be one of the WdTableFormat constants.

  • ApplyBorders
    Type: System.Object%

    true to apply the border properties of the specified format.

  • ApplyShading
    Type: System.Object%

    true to apply the shading properties of the specified format.

  • ApplyFont
    Type: System.Object%

    true to apply the font properties of the specified format.

  • ApplyColor
    Type: System.Object%

    true to apply the color properties of the specified format.

  • ApplyHeadingRows
    Type: System.Object%

    true to apply the heading-row properties of the specified format.

  • ApplyLastRow
    Type: System.Object%

    true to apply the last-row properties of the specified format.

  • ApplyFirstColumn
    Type: System.Object%

    true to apply the first-column properties of the specified format.

  • ApplyLastColumn
    Type: System.Object%

    true to apply the last-column properties of the specified format.

  • AutoFit
    Type: System.Object%

    true to decrease the width of the table columns as much as possible without changing the way text wraps in the cells.

Return Value

Type: Microsoft.Office.Interop.Word.Table
A Table.

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Examples

The following code example adds a Bookmark control with text to the document and then converts the text in the bookmark to a table.

This example is for a document-level customization.

Private Sub BookmarkConvertToTable()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    Bookmark1.Text = "1,2,3,4,5,6" 

    Dim Table1 As Word.Table = Bookmark1.ConvertToTable( _
        Separator:=Word.WdTableFieldSeparator.wdSeparateByCommas, _
        Format:=Word.WdTableFormat.wdTableFormatClassic1, _
        ApplyBorders:=True, AutoFit:=True, AutoFitBehavior:= _
        Word.WdAutoFitBehavior.wdAutoFitContent)

End Sub
private void BookmarkConvertToTable()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "1,2,3,4,5,6";

    object Separator = Word.WdTableFieldSeparator.wdSeparateByCommas;
    object Format = Word.WdTableFormat.wdTableFormatClassic1;
    object ApplyBorders = true;
    object AutoFit = true;
    object AutoFitBehavior = Word.WdAutoFitBehavior.wdAutoFitContent;

    Word.Table Table1 = bookmark1.ConvertToTable(ref Separator,
        ref missing, ref missing, ref missing, ref Format,
        ref ApplyBorders, ref missing, ref missing, ref missing,
        ref missing, ref missing, ref missing,
        ref missing, ref AutoFit, ref AutoFitBehavior,
        ref missing);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace