Input Photo Macro

Bosshog51

New Member
Joined
Jun 20, 2019
Messages
3
Hello!

I am looking to create a macro that will input a photo intoa spreadsheet in a certain location. Ifound the below from a different user online:

Sub GetPic1()
Dim fNameAndPath As Variant
Dim img As Picture
fNameAndPath =Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
Set img =ActiveSheet.Pictures.Insert(fNameAndPath)
With img
'Resize Pictureto fit in the range....
.Left =ActiveSheet.Range("D12").Left
.Top =ActiveSheet.Range("D12").Top
.Width =ActiveSheet.Range("D12:I12").Width
.Height =ActiveSheet.Range("D12:D27").Height
.Placement = 1
.PrintObject =True
End With
End Sub

The issue I am having is when someone uses it on a differentcomputer and emails me the excel file, I am not able to view the photo in thespreadsheet. It says “The linked imagecannot be displayed. The file may havebeen moved, renamed, or deleted. Verifythat the link points to the correct file and location.”

I do not know much about VBA or writing macros in excel, butit looks like it is trying to access the path to the file on the computer inwhich the photo is located? Is there anyway to change this macro so that it doesn’t link to the photo’s path on theuser’s computer and just pastes the image? I want the image to be viewable by someone who is accessing thespreadsheet on a different computer.

Thank you!

~ Bosshog
 

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,240
Is the workbook saved before being sent in an email ?
 

Watch MrExcel Video

Forum statistics

Threads
1,099,827
Messages
5,471,014
Members
406,739
Latest member
Temeraire24

This Week's Hot Topics

Top