View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.newusers,microsoft.public.excel.programming
MS[_4_] MS[_4_] is offline
external usenet poster
 
Posts: 3
Default Way to automate adding pictures in a series in Excel?

So, should the macro below work to insert the pictures automatically with
the correspondence between the filename and the row #, to know which picture
goes in which cell in the column?

Where it says C2-C4, I replace the Letter with the column number in which I
have the pictures, and replace the number range with the range of rows that
will have pictures inserted? Where it says "C:\Windows" replace that with
the folder where those numbered pictures are located?

What about the text following that in the same line--& cell.Row & ".jpg."
Just like that? Or substitute cell.Row with the first row in which a picture
should be inserted? (Isn't that information already there, in the range
"C2:C4"?) Do I preceded the ".jpg" with the number of the first photo to be
inserted?

By "uncomment", do you mean take away the ' at the bottom of those two
lines?

Sorry for the "dummy" questions, but I am a novice at this.

So I can click on "Write Macro", and paste in that text, with the changes
mentioned above? Anything I missed that requires my input , before saving
the macro?

Thanks a lot for writing it. :-)

"Tom Ogilvy" wrote in message
...
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.