Export (0) Print
Expand All
Expand Minimize

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)

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

Separator
Type: System.Object

Specifies the character used to separate text into cells. Can be a character or one of the following WdTableFieldSeparator constants: wdSeparateByCommas, wdSeparateByDefaultListSeparator, wdSeparateByParagraphs, or wdSeparateByTabs.

If this argument is omitted, the value of the DefaultTableSeparator property is used.

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.

AutoFitBehavior
Type: System.Object

Sets the AutoFit rules for how Word sizes a table. Can be one of the following WdAutoFitBehavior constants: wdAutoFitContent, wdAutoFitFixed, wdAutoFitWindow. If DefaultTableBehavior is wdWord8TableBehavior, this argument is ignored.

DefaultTableBehavior
Type: System.Object

Sets a value that specifies whether Word automatically resizes cells in a table to fit the contents (AutoFit). Can be one of the following WdDefaultTableBehavior constants: wdWord8TableBehavior, wdWord9TableBehavior.

Return Value

Type: Table
A Table.

Optional Parameters

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

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 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);
}

Show:
© 2015 Microsoft