Way to automate adding pictures in a series in Excel?
Sub AddPictures()
Dim pic As Picture
'ActiveSheet.Pictures.Delete
For Each cell In Range("C2:C4")
cell.Select
Set pic = _
ActiveSheet.Pictures. _
Insert("C:\WINDOWS\" & cell.Row & ".jpg")
pic.Top = cell.Top
pic.Left = cell.Left
' pic.Width = cell.Width
' pic.Height = cell.Height
Next
End Sub
Change C2:C4 to represent the cells where you want the picture.
If you want the pictures to exactly cover the cell, then uncomment the Width
and Height commands.
--
Regards,
To Ogilvy
MS wrote in message
...
I'm putting a column of pictures of people next to a column with their
names. If I have the pictures together in a folder, with the photo file
names numbered with the corresponding row numbers that the pictures go in,
is there a way to record a macro so that (for instance) 28.jpg will go
into
the picture column in row #28, then 29.jpg will go into the picture column
in row #29, etc. In other words, insert a whole series of pictures
(filenames the same as their appropriate row numbers) in their correct
places, by initiating one macro?
If anyone has any idea of how that could be done, I would greatly
appreciate
any suggestions on how to do that.
|