简体   繁体   中英

How do I copy Data from a excel in to word and keep its formatting

I have been trying to copy text from excel in to word, and retain the bold formatting on the text, but not the cell. When I try manually copy and paste over a cell the text is copied but not the cell itself. When I try repeat this using vb (as shown below) the cell is also copied over

With wrdDoc

    .Content.Font.Name = "Times New Roman"
    .Content.Font.Size = 11
    .Content.InsertParagraphAfter
    .Content.InsertParagraphAfter
    With Worksheets("Sheet1")
        Cells(1, 1).Select
        Cells(1, 1).Copy
    End With
    .Content.InsertAfter "AddTableHere"
    .Content.Find.Execute FindText:="AddTableHere", ReplaceWith:="^c"


End With

Has anyone any suggestions on how I could do this?

Thanks

Word中的Selection对象具有一个PasteExcelTable方法,该方法可能符合要求-有关详细信息,请参见MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM