I spent few hours looking for help on the forum. But my level of VBA is not on such level that I would be able to implement and test the changes in code.
In short, I have an excel file and I want to send Range selected via outlook email. Many tutorials here and this is working fine.
But my trouble is the formatting. No matter how I try the row height in the outlook email keeps messing up and graphs are overlapping the tables etc. The rows width and object positions are ok though.
So is there any trick, how to keep the formatting exactly the same as in the excel file?
Here is the code for sending the range via email which is working:
Private Sub Workbook_Open()
ActiveWorkbook.RefreshAll
'Working in Excel 2002-2016
Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range
Sheets("Data").Select
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Fill in the Worksheet/range you want to mail
'Note: if you use one cell it will send the whole worksheet
Set Sendrng = Worksheets("Data").Range("A1:S600")
'Remember the activesheet
Set AWorksheet = ActiveSheet
With Sendrng
'Select the worksheet with the range you want to send
.Parent.Select
'Remember the ActiveCell on that worksheet
Set rng = ActiveCell
'Select the range you want to mail
.Select
' Create the mail and send it
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
'.Introduction = "Hello all."
With .Item
.To = "xxx@zzz.eu"
.CC = "xxx@zzz.eu"
.BCC = ""
.Subject = "xxx" & Format(Worksheets("Support").Range("A1").Value, "dd.mm.yyyy")
.Send
End With
End With
'select the original ActiveCell
rng.Select
End With
'Activate the sheet that was active before you run the macro
AWorksheet.Select
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
ActiveWorkbook.Save
Application.Quit
End Sub