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
- 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: 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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.