the below code work properly. the code from Hans..but i want to modified like this:
here this steps:
this step macro can do it:
1. first time, select your range/cell that you want export NOT your shape/picture, then run macro
2. browse folder location to save...
3. save as .png format
4. the macro code working in active sheet (any name sheet).
Code: Select all
Sub ExportAsPNG()
Dim wsh As Worksheet
Dim shp As Shape
Dim fil As Variant
Dim cho As ChartObject
On Error Resume Next
Set shp = Selection.ShapeRange(1)
On Error GoTo 0
If shp Is Nothing Then
MsgBox "Please select a shape/picture, then try again!", vbExclamation
Exit Sub
End If
fil = Application.GetSaveAsFilename(InitialFileName:="*.png", FileFilter:="PNG files (*.png), *.png")
If fil = False Then
MsgBox "You didn't specify a filename!", vbExclamation
Exit Sub
End If
Set wsh = ActiveSheet
Set cho = wsh.ChartObjects.Add(Left:=shp.Left, Top:=shp.Top, Width:=shp.Width, Height:=shp.Height)
shp.Copy
cho.Select
ActiveChart.Paste
ActiveChart.Export Filename:=fil, FilterName:="PNG"
cho.Delete
End Sub
susant