muhammad susanto
Well-known Member
- Joined
- Jan 8, 2013
- Messages
- 2,102
- Office Version
- 365
- 2021
- Platform
- Windows
hi all...
i'm looking for vba code to save range of cells as image in Excel (.jpg or .png format)
with step or criteria like this:
1. first macro run in active sheet (any name sheet)
2. when i click run macro show message "please, select your range.."
3. then browse location Save in....
4. i don't use image for send email
i found code but i don't know use and modified
would you help me out greatly appreciated..
.susanto
i'm looking for vba code to save range of cells as image in Excel (.jpg or .png format)
with step or criteria like this:
1. first macro run in active sheet (any name sheet)
2. when i click run macro show message "please, select your range.."
3. then browse location Save in....
4. i don't use image for send email
i found code but i don't know use and modified
VBA Code:
Sub createJpg(SheetName As String, xRgAddrss As String, nameFile As String)
Dim xRgPic As Range
Dim xShape As Shape
ThisWorkbook.Activate
Worksheets(SheetName).Activate
Set xRgPic = ThisWorkbook.Worksheets(SheetName).Range(xRgAddrss)
xRgPic.CopyPicture
With ThisWorkbook.Worksheets(SheetName).ChartObjects.Add(xRgPic.Left, xRgPic.Top, xRgPic.Width, xRgPic.Height)
.Activate
For Each xShape In ActiveSheet.Shapes
xShape.Line.Visible = msoFalse
Next
.Chart.Paste
.Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG"
End With
Worksheets(SheetName).ChartObjects(Worksheets(SheetName).ChartObjects.Count).Delete
Set xRgPic = Nothing
End Sub
.susanto