PasteExcelTable Method

Microsoft Word Visual Basic

expression.PasteExcelTable(LinkedToExcel, WordFormatting, RTF)

expression    Required. An expression that returns one of the objects in the Applies To list.

LinkedToExcel   Required Boolean. True links the pasted table to the original Excel file so that changes made to the Excel file are reflected in Microsoft Word.

WordFormatting   Required Boolean. True formats the table using the formatting in the Word document. False formats the table according to the original Excel file.

RTF   Required Boolean. True pastes the Excel table using Rich Text Format (RTF). False pastes the Excel table as HTML.

Example

This example pastes an Excel table into the active document. The parameters specify that the pasted table is linked to the Excel file, retains the original Excel formatting, and is pasted as RTF. This example assumes that the Clipboard contains an Excel table.

Sub PasteExcelFormatted()
    Selection.PasteExcelTable _
        LinkedToExcel:=True, _
        WordFormatting:=False, _
        RTF:=True
End Sub