Hello,
I am trying to insert a picture such that it spans the width and high of range G4:G8, which is about 1.13 in by 1.2 in according to the format graphic size & properties.
Unfortunately, my picture continues to be inserted in range E4:E8 and *I DONT KNOW WHY*
This is very frustrating and any help would be extremely appreciated - code below:
I am trying to insert a picture such that it spans the width and high of range G4:G8, which is about 1.13 in by 1.2 in according to the format graphic size & properties.
Unfortunately, my picture continues to be inserted in range E4:E8 and *I DONT KNOW WHY*
This is very frustrating and any help would be extremely appreciated - code below:
Code:
Sub GetPic()
' This macro is designed to allow users to click the NPC picture and automatically add their own from a file on their explorer
'
' Variables
'
Dim fNameAndPath As Variant
Dim img As Picture
Dim rng As Range
Set rng = ActiveSheet.Range("G4:G8")
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture to be imported") ' Opening windows browser to find picture
On Error GoTo errHandler
If fNameAndPath = False Then MsgBox ("Error importing picture, please try again.")
Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
' Resizing image to fit inside the area
With img
.Left = rng.Left
.Top = rng.Top
.Width = rng.Width
.Height = rng.Height
.Placement = 1
.PrintObject = True
End With
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not insert picture"
Resume exitHandler
End Sub
Last edited by a moderator: