Insert Picture in Excel macro, after crop it, save it to a file [Solved/Closed]

Ask a question juancarlosmm 2Posts Tuesday October 25, 2016Registration date October 25, 2016 Last seen - Last answered on Oct 25, 2016 at 05:04 PM by juancarlosmm
Hello friends, I need to open a macro, after place the name in A1 cell, push a button to insert a picture, base on A1 name, then, after crop it and resize it, save just the cropped picture to a new file named A1 & "b".jpg
plus moins
Thank you all,
I found the solution here

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

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


With ActiveChart
End With

.ChartObjects(1).Chart.Export Filename:="MyPic.jpg", FilterName:="jpg"
End With

Application.ScreenUpdating = True
Exit Sub

MsgBox "You must select a picture"
End Sub

Member requests are more likely to be responded to.

Members can monitor the statuses of their requests from their account pages.

A CCM membership gives you access to additional options.

Not a member yet?

Sign up now. It takes less than a minute and is completely free!