Ciao a tutti
La macro va ad aprire una cartella in cui selezionando l'immagine voluta questa viene ridimensionata in funzione della cella di destinazione.
Non riesco a centrare la foto.
Il codice è il seguente:
Sub InsertImageFromFolder()
Dim myPicture As String, myRange As Range 'set of variables for the image and a selected cell
'defining image formats for import
myPicture = Application.GetOpenFilename _
("Pictures (.gif; .jpg; .bmp; .tif),.gif; .jpg; .bmp; .tif", _
, "Choose image for insert")
Set myRange = Selection 'defining the selected cells
'Set myRange = Application.InputBox("Select your range...", Type:=8) 'message to select the destination cell - option
InsertAndSizePic myRange, myPicture 'calling the procedure for resizing images
End Sub
Sub InsertAndSizePic(Target As Range, PicPath As String)
'procedure to insert a picture and adjust the size of the destination cell
Dim p As Picture
Application.ScreenUpdating = False
Set p = ActiveSheet.Pictures.Insert(PicPath)
If Target.Cells.Count = 1 Then Set Target = Target.MergeArea
With Target
p.Top = .Top + (.Height - p.Height) / 2
p.Left = .Left + (.Width - p.Width) / 2
p.Width = .Width * 0.95
p.Height = .Height * 0.95
End With
End Sub
In allegato trovate il file excel.
Grazie per l'aiuto
[Modificato da mat.p 06/03/2019 19:47]