L
Lil
Hi,
I am new to writing Excel Macros and have been working on this for
couple of days now and can't seem to get it going. Someone pleas
help!!
I have a worksheet in which one column holds the file name. I need t
find this file in a directory on the C:/drive and display this pictur
in a cell in the appropriate row.
Here's some code that I tried but didn't work:
Public Sub DisplayPics()
Dim b As Long
Dim strFilePath As String
Dim pic As Shape
'Start at row 2 as the first row is a header row.
b = 2
Set sheet = Worksheets("Sheet2")
count = sheet.UsedRange.Rows.count
'Insert column to insert picture.
Worksheets("Sheet2").Cells(1, 3).EntireColumn.Insert
'look for the jpg file name in column i, find the file in the loca
drive and insert
'the picture in column C
While b <= count
If Len(sheet.Cells(b, 1)) > 0 Then
strFilePath = "C:/graphics/" & Cells(b, 9).Value
If Dir(strFilePath) = "" Then
Worksheets("Sheet2").Cells(b, 3).Value = "No Phot
Available"
Else
Worksheets("Sheet2").Cells(b, 3).Pictures.Inser
(strFilePath)
Set pic = ActiveSheet.Shapes(Activesheeet.Shape.count)
Selection.ShapeRange.ScaleWidth 0.5, msoFalse
msoScaleFromTopLeft 'This is on a single line
Selection.ShapeRange.ScaleHeight 0.5, msoFalse
msoScaleFromTopLeft 'This is on a single line
Rows(b).RowHeight = 90
End If
End If
b = b + 1
Wend
End Sub
At this line "Worksheets("Sheet2").Cells(b, 3).Pictures.Inser
(strFilePath)", the error is: "Object does not support this property o
method"
Any suggestions would be great.
Many thanks in advance for your help,
Lillian
I am new to writing Excel Macros and have been working on this for
couple of days now and can't seem to get it going. Someone pleas
help!!
I have a worksheet in which one column holds the file name. I need t
find this file in a directory on the C:/drive and display this pictur
in a cell in the appropriate row.
Here's some code that I tried but didn't work:
Public Sub DisplayPics()
Dim b As Long
Dim strFilePath As String
Dim pic As Shape
'Start at row 2 as the first row is a header row.
b = 2
Set sheet = Worksheets("Sheet2")
count = sheet.UsedRange.Rows.count
'Insert column to insert picture.
Worksheets("Sheet2").Cells(1, 3).EntireColumn.Insert
'look for the jpg file name in column i, find the file in the loca
drive and insert
'the picture in column C
While b <= count
If Len(sheet.Cells(b, 1)) > 0 Then
strFilePath = "C:/graphics/" & Cells(b, 9).Value
If Dir(strFilePath) = "" Then
Worksheets("Sheet2").Cells(b, 3).Value = "No Phot
Available"
Else
Worksheets("Sheet2").Cells(b, 3).Pictures.Inser
(strFilePath)
Set pic = ActiveSheet.Shapes(Activesheeet.Shape.count)
Selection.ShapeRange.ScaleWidth 0.5, msoFalse
msoScaleFromTopLeft 'This is on a single line
Selection.ShapeRange.ScaleHeight 0.5, msoFalse
msoScaleFromTopLeft 'This is on a single line
Rows(b).RowHeight = 90
End If
End If
b = b + 1
Wend
End Sub
At this line "Worksheets("Sheet2").Cells(b, 3).Pictures.Inser
(strFilePath)", the error is: "Object does not support this property o
method"
Any suggestions would be great.
Many thanks in advance for your help,
Lillian