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
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Is the workbook saved before being sent in an email ?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top