How to keep formats when I copy a range from Excel to outlook

前端 未结 2 654
醉话见心
醉话见心 2020-12-11 12:59

Hello i have an Excel table with some formats 10(Red) -> 15(Green), but at the end I loose all the formats i have in my excel. I use the ne

相关标签:
2条回答
  • 2020-12-11 13:32

    While OP's accepted answer may have worked for him, I don't believe it's the right answer.

    If you want to keep the formatting from your source you need to use xlPasteAllUsingSourceTheme

    Code:

    With TempWB.Sheets(1)
            .Cells(1).PasteSpecial Paste:=8
            '.Cells(1).PasteSpecial xlPasteValues, , False, False
            '.Cells(1).PasteSpecial xlPasteFormats, , False, False
            .Cells(1).PasteSpecial xlPasteAllUsingSourceTheme, , False, False
            .Cells(1).Select
            Application.CutCopyMode = False
            On Error Resume Next
            .DrawingObjects.Visible = True
            .DrawingObjects.Delete
            On Error GoTo 0
    End With
    
    0 讨论(0)
  • 2020-12-11 13:40

    Ok I found how to made it, in rangetoHtml(), when is pasting the values I changed the code for:

        With TempWB.Sheets(1)
            '.Cells(1).PasteSpecial Paste:=8
            .Cells(1).PasteSpecial
            '.Cells(1).PasteSpecial xlPasteValues, , False, False
            '.Cells(1).PasteSpecial xlPasteFormats, , False, False
            '.Cells(1).Select
            Application.CutCopyMode = False
            On Error Resume Next
            .DrawingObjects.Visible = True
            .DrawingObjects.Delete
            On Error GoTo 0
        End With
    

    Becase If I made just a copy and paste I dont lost any format.

    0 讨论(0)
提交回复
热议问题