OaklandJim
Well-known Member
- Joined
- Nov 29, 2018
- Messages
- 855
- Office Version
- 365
- Platform
- Windows
I've spent some time looking for this. I thought it would be easy to find. BUT I was unable to find what I need. If nothing else most examples are for a chart. I want to save a range as a jpg, not a chart.
Here is some hacky code that makes a picture of a range but I cannot figure out how to save that picture as a file.
Here is some hacky code that makes a picture of a range but I cannot figure out how to save that picture as a file.
VBA Code:
Sub Macro3()
'
Dim sFolder As String
Dim sPictureName As String
sFolder = "C:\Users\Jim\Desktop\"
sPictureName = "TableRange"
Range("B14:D20").Copy
ActiveSheet.Pictures.Paste.Select
With Selection
.ShapeRange.Name = "TablePicture"
.Name = "TablePicture"
' Object does not support this property or method
'.SaveAs Filename:=sFolder & sFolder & ".jpg"
'.Shapes.SaveAs Filename:=sFolder & sPictureName & ".jpg"
'.Shapes.Export Environ("USERPROFILE") & "\Desktop\" & sPictureName & ".jpg"
'.Export Filename:=Environ("USERPROFILE") & "\Desktop\" & sPictureName & ".jpg", Filtername:="JPG"
'.Cut
End With
' Object does not support this property or method
'ActiveSheet.ShapeRange(sPictureName).Export Environ("USERPROFILE") & "\Desktop\" & sPictureName & ".jpg"
' Shape not found...but it exists?
'ActiveSheet.Shapes(sPictureName).Export Environ("USERPROFILE") & "\Desktop\" & sPictureName & ".jpg"
Application.CutCopyMode = False
End Sub