开发者

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

开发者 https://www.devze.com 2023-01-18 11:46 出处:网络
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

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.Inse开发者_开发技巧rtAfter "AddTableHere"
    .Content.Find.Execute FindText:="AddTableHere", ReplaceWith:="^c"


End With

Has anyone any suggestions on how I could do this?

Thanks


The Selection object in Word has a PasteExcelTable method which might fit the bill - see MSDN for details

0

精彩评论

暂无评论...
验证码 换一张
取 消