i am totaly new here. I want to export a specific excel range as a jpeg and i use vba for that.
I produced also the vba code but i have a small problem: when i run the the code i export a jpeg file in my excel sheet but i want to export it to specific path at the explorer. Maybe you can help be :)
Option Explicit
Sub Range_To_Image()
Dim objPict As Object, objChrt As Chart
Dim rngImage As Range, strFile As String
On Error GoTo ErrExit
With Sheets("Tabelle1") 'Tabellenname - Anpassen!
Set rngImage = .Range("A1:C20")
rngImage.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
Set objPict = .Shapes(.Shapes.Count)
strFile = "C:\Users\daniel\Desktop\Sales Report\haus.jpg" 'Pfad und Dateiname für das Bild
objPict.Copy
Set objChrt = .ChartObjects.Add(1, 1, objPict.Width + 8, objPict.Height + 8).Chart
objChrt.Paste
objChrt.Export strFile
objChrt.Parent.Delete
objPict.Delete
End With
ErrExit:
Set objPict = Nothing
Set objChrt = Nothing
Set rngImage = Nothing
End Sub