I need to convert a range to a picture and saved that picture as a JPEG which I can then use for different purposes (e.g. email sending). Now I have switched to O365 compared to Excel2007 and with that switch the picture is always empty with a border only. It seems like there were any issues within my code which I have attached below. Please do you have any idea what the problem could be?
Thanks and best regards, Susann
Sub Range_To_Image()
'erstellt von den markierten Zellen eine Bilddatei (GIF)
Dim Zellbereich As Range
Dim Anz_Markierungen As Integer
Dim Bild As Picture
Dim Diagramm As ChartObject
On Error GoTo Hell 'falls "Abbrechen" gedrückt wird
'Zellen markieren (Bildbereich)
Set Zellbereich = Sheets("OE Daily Summary").Range("A6:O66")
On Error GoTo 0
Application.ScreenUpdating = False
Zellbereich.Copy
Worksheets.Add
Set Bild = ActiveSheet.Pictures.Paste(Link:=True)
Bild.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set Diagramm = ActiveSheet.ChartObjects.Add(0, 0, Bild.Width, Bild.Height)
With Diagramm
.Chart.Paste
.Chart.Export Filename:=ActiveWorkbook.Path & "\OE_Daily_Summary" & ".jpg", FilterName:="jpg"
End With
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.ScreenUpdating = True
Set Diagramm = Nothing
Set Bild = Nothing
Set Zellbereich = Nothing
Exit Sub
Hell:
MsgBox "", , "Abbruch"
End Sub