Hello, I have little to no experience in righting codes. I have managed to get my hands on the code bellow .
Function: insert's picture in excel from location
The problem i have is once I send the file to another user, if he/she will not have an opened connection to the location from were the pictures were inserted , they will get an error instead of the picture. It's something with "ActiveSheet.Pictures.Insert" that requires an established connection to the source, even thow the pictures were inserted in the sheet.
"Shapes.Addpicture" and "SaveWithDocument" should solve this problem. I`ve tried myself to modify the code with no result.
Can you please help me ?
![]()
Sub Picture() Dim picname As String Dim pasteAt As Range Dim lThisRow As Long lThisRow = 2 Do While (Cells(lThisRow, 2) <> "") 'Range("AB2").Select 'This is where picture will be inserted Set pasteAt = Cells(lThisRow, 28) pasteAt.Select 'This is where picture will be inserted 'Dim picname As String 'picname = Range("A2") 'This is the picture name picname = Cells(lThisRow, 1) 'This is the picture name ActiveSheet.Pictures.Insert("C:\Users\xxxxxxxxxx\" & picname & ".jpg").Select 'Path to where pictures are stored ''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' This resizes the picture ''''''''''''''''''''''''''''''''''''''''''''''''''''''' With Selection '.Left = Range("A2").Left '.Top = Range("A2").Top .Left = pasteAt.Left .Top = pasteAt.Top .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = 105 .ShapeRange.Rotation = 0# End With lThisRow = lThisRow + 1 Loop Range("AA1").Select Application.ScreenUpdating = True Exit Sub
Bookmarks