I wrote a code where i can browse a picture and put it in a selected cell in a small size. When clicking on the photo, it will get bigger. The problem is when it gets bigger it looses its quality and not well shown. How can i keep the same quality of the image ?Thank you for your help
VBA Code:
Sub InsertPicture()
Dim cel As Range, Pic As Object
With Application.InputBox("Select Cell from Column B to place a Photo and click OK", "Browse Picture", , , , , , 8)
Set Pic = ActiveSheet.Shapes.AddPicture(FileName:=GetImage, _
linktofile:=msoFalse, savewithdocument:=msoCTrue, Left:=0, Top:=0, Width:=-1, Height:=-1)
Pic.Top = .Top: Pic.Left = .Left: Pic.Height = .Height
End With
With Pic
.Name = "P" & Format(Now, "yymmddhhmmss")
.OnAction = "'" & ActiveWorkbook.Name & "'!Resize"
.ZOrder msoSendToBack
End With
End Sub
Private Function GetImage() As String
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.ButtonName = "Submit"
.Title = "Select an image file"
.Filters.Add "Image", "*.gif; *.jpg; *.jpeg", 1
If .Show = -1 Then GetImage = .SelectedItems(1) Else End
End With
End Function
Sub Resize()
Dim shp As Shape: Set shp = ActiveSheet.Shapes(Application.Caller)
With shp.TopLeftCell
.Activate
If shp.Height > .Height Then shp.Height = .Height Else shp.Height = .Height * 7
End With
End Sub