Insert Picture in Excel macro, after crop it, save it to a file
Solved/Closed
juancarlosmm
Posts
2
Registration date
Tuesday October 25, 2016
Status
Member
Last seen
October 25, 2016
-
Oct 25, 2016 at 02:06 PM
juancarlosmm Posts 2 Registration date Tuesday October 25, 2016 Status Member Last seen October 25, 2016 - Oct 25, 2016 at 05:04 PM
juancarlosmm Posts 2 Registration date Tuesday October 25, 2016 Status Member Last seen October 25, 2016 - Oct 25, 2016 at 05:04 PM
Related:
- Crop picture in excel
- Number to words in excel - Guide
- Convert picture to shape powerpoint - Guide
- Gif in excel - Guide
- Microsoft picture manager download - Download - Image viewing and management
- Marksheet in excel - Guide
1 response
juancarlosmm
Posts
2
Registration date
Tuesday October 25, 2016
Status
Member
Last seen
October 25, 2016
Oct 25, 2016 at 05:04 PM
Oct 25, 2016 at 05:04 PM
Thank you all,
I found the solution here
https://stackoverflow.com/questions/18232987/export-pictures-from-excel-file-into-jpg-using-vba
Here is the code, regards
Option Explicit
Sub ExportMyPicture()
Dim MyChart As String, MyPicture As String
Dim PicWidth As Long, PicHeight As Long
Application.ScreenUpdating = False
On Error GoTo Finish
MyPicture = Selection.Name
With Selection
PicHeight = .ShapeRange.Height
PicWidth = .ShapeRange.Width
End With
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Selection.Border.LineStyle = 0
MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)
With ActiveSheet
With .Shapes(MyChart)
.Width = PicWidth
.Height = PicHeight
End With
.Shapes(MyPicture).Copy
With ActiveChart
.ChartArea.Select
.Paste
End With
.ChartObjects(1).Chart.Export Filename:="MyPic.jpg", FilterName:="jpg"
.Shapes(MyChart).Cut
End With
Application.ScreenUpdating = True
Exit Sub
Finish:
MsgBox "You must select a picture"
End Sub
I found the solution here
https://stackoverflow.com/questions/18232987/export-pictures-from-excel-file-into-jpg-using-vba
Here is the code, regards
Option Explicit
Sub ExportMyPicture()
Dim MyChart As String, MyPicture As String
Dim PicWidth As Long, PicHeight As Long
Application.ScreenUpdating = False
On Error GoTo Finish
MyPicture = Selection.Name
With Selection
PicHeight = .ShapeRange.Height
PicWidth = .ShapeRange.Width
End With
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Selection.Border.LineStyle = 0
MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)
With ActiveSheet
With .Shapes(MyChart)
.Width = PicWidth
.Height = PicHeight
End With
.Shapes(MyPicture).Copy
With ActiveChart
.ChartArea.Select
.Paste
End With
.ChartObjects(1).Chart.Export Filename:="MyPic.jpg", FilterName:="jpg"
.Shapes(MyChart).Cut
End With
Application.ScreenUpdating = True
Exit Sub
Finish:
MsgBox "You must select a picture"
End Sub