DonAndress
Active Member
- Joined
- Sep 25, 2011
- Messages
- 365
- Office Version
- 365
- 2021
- Platform
- Windows
Hello,
I am trying to get a better copy/paste method. Generally I use Ron de Bruin's code (Mail Range or Selection).
But from my worksheet I am copying a pivot table and I'd like to paste it into email body with all formats, including shading and borders, as you usually do with ctrl+C -> ctrl+V.
So when copying manually, either to other excel sheet, or to outlook email body, all formatting is kept. When I use the below code, shading and borders are lost.
May I ask for a hint on how to keep all of it?
There is no point of me quoting here all Ron's code, I will just paste only this part of code which is responsible for pasting into new file:
I am trying to get a better copy/paste method. Generally I use Ron de Bruin's code (Mail Range or Selection).
But from my worksheet I am copying a pivot table and I'd like to paste it into email body with all formats, including shading and borders, as you usually do with ctrl+C -> ctrl+V.
So when copying manually, either to other excel sheet, or to outlook email body, all formatting is kept. When I use the below code, shading and borders are lost.
May I ask for a hint on how to keep all of it?
There is no point of me quoting here all Ron's code, I will just paste only this part of code which is responsible for pasting into new file:
VBA Code:
Set TempWB = Workbooks.Add(1)
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 'sorry, I added this line as a test, doesn't work
.Cells(1).Select
Application.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With