Searched forum for two days and tried everything related to inserting pictures to get this to work. So, HELP! Please!
I have to file an insurance claim due to a fire in my home. I have a folder with .jpg photos located at C:\InsClaimOnlinePhotos\ . Im working with Excel 2003. I am trying to put the picture of the damaged protery in Column A on the same row as the detail about that damaged property using the ActiveSheet.Pictures.Insert function. The name of the picture is located in Column B. There are multiple sheets in the Excel book and each contains from 10 to over 700 rows. I would like to run the macro based on the active sheet to add the pictures one sheet at a time. I would like the pictures to be about 1.2" High by 1.6" Wide and be actually be within the cell of Column A of the row where the detail information is located. I have played with writing my own code, pieces of others code and full code sets I found in the Forum. Nothing works. Below is the best I found so far but, it uses Column C for the placement of the pictues.
When I try to run the below code I get Run-Time Error "1004" "Unable to get the insert Property of the Picture class".
I'm not sure if this code should work in Excel 2003 or not.
Thank you in advance for your help.
Here is the code:
![]()
Sub Picture() 'Assumptions '1. picture names are found in col B starting at B2 '2. You want to paste each picture at different location '3. where to paste the picture identified in col B, is found in col C starting at C2 Dim picname As String Dim pasteAt As Integer Dim lThisRow As Long lThisRow = 2 Do While (Cells(lThisRow, 2) <> "") pasteAt = Cells(lThisRow, 3) Cells(pasteAt, 1).Select 'This is where picture will be inserted picname = Cells(lThisRow, 2) 'This is the picture name ActiveSheet.Pictures.Insert("C:\InsClaimOnlinePhotos\" & picname & ".jpg").Select 'Path to where pictures are stored ''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' This resizes the picture ''''''''''''''''''''''''''''''''''''''''''''''''''''''' With Selection '.Left = Range("A6").Left '.Top = Range("A6").Top .Left = Cells(pasteAt, 1).Left .Top = Cells(pasteAt, 1).Top .ShapeRange.LockAspectRatio = msoFalse .ShapeRange.Height = 100# .ShapeRange.Width = 80# .ShapeRange.Rotation = 0# End With lThisRow = lThisRow + 1 Loop Range("A10").Select Application.ScreenUpdating = True Exit Sub ErrNoPhoto: MsgBox "Unable to Find Photo" 'Shows message box if picture not found Exit Sub Range("B20").Select End Sub
Bookmarks