manicmighty
New Member
- Joined
- Apr 18, 2018
- Messages
- 15
I have used the below VB code to copy a range from my excel sheet to create an image file which I then add to the body of an email:
Once the file has been created it then sometimes displays the image but more often than not it comes back as blank showing just a border; can anyone advise on how to amend the code to ensure the image is displayed each time I run the report.
Thanks
Sub CreateEmailImageEOD()
Selection.CopyPicture xlScreen, xlBitmap
Dim mchart As ChartObject
Set mchart = Sheets("Report_ENDOFDAY").ChartObjects.Add(0, 2500, 50, 50)
Sheets("Report_ENDOFDAY").Select
Range("B2:AB35").Select
mchart.Name = "EOD"
mchart.Width = Selection.Width
mchart.Height = Selection.Height
Sheets("Report_ENDOFDAY").ChartObjects("EOD").Activate
ActiveChart.Paste
ActiveChart.Export ThisWorkbook.Path & "EOD.bmp", "bmp"
mchart.Delete
End Sub
Once the file has been created it then sometimes displays the image but more often than not it comes back as blank showing just a border; can anyone advise on how to amend the code to ensure the image is displayed each time I run the report.
Thanks
Sub CreateEmailImageEOD()
Selection.CopyPicture xlScreen, xlBitmap
Dim mchart As ChartObject
Set mchart = Sheets("Report_ENDOFDAY").ChartObjects.Add(0, 2500, 50, 50)
Sheets("Report_ENDOFDAY").Select
Range("B2:AB35").Select
mchart.Name = "EOD"
mchart.Width = Selection.Width
mchart.Height = Selection.Height
Sheets("Report_ENDOFDAY").ChartObjects("EOD").Activate
ActiveChart.Paste
ActiveChart.Export ThisWorkbook.Path & "EOD.bmp", "bmp"
mchart.Delete
End Sub