Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert images from folder, based on name 1

Status
Not open for further replies.

johng75

IS-IT--Management
Jul 14, 2004
247
US
i have a listing of hundreds of products and units of measure, in an excel spread sheet
(example)
product XYZ, case, box, each

in a folder on my desktop i have an image for every product, and unit of measure
(example)
UM-Product.JPG


i would like to know, is there a way to put together a 'report' listing every product number, the unit of measue, and have the correct image next to it?


nothing fancy, just simple

product

UM - image
UM - image
UM - image

product

UM - image

etc.....



if it were just a hundred or so i would just take the time and insert image, but i have several.....


any ideas would be appreciated, does not have to stay in excel, can use another program to create, once the report is created, it will be printed and distributed



running Office XP Pro

 
Hi John,

You could use a macro like the following, where the product names are in column A, starting at row 1, and these are the same as the image names in the folder 'C:\Image Folder\':
Code:
Sub InsPics()
Dim Pic As Picture
Dim Product As String
Dim i As Integer
Dim vPos As Single
vPos = -1 * Range("A1").Height
For i = 1 To Range("A65536").End(xlUp).Row
  With Range("A" & i)
    vPos = vPos + .Height
    Product = .Value
    Set Pic = .Parent.Pictures.Insert("C:\Image Folder\" & Product & ".jpg")
    With Pic
      .Name = Product
      ' Set the distance, in points, from the left edge of the object to the left edge of column A
      .Left = 100
      ' Set the distance, in points, from the top edge of the object to the top of row 1
      .Top = vPos
      .Height = 25
    End With
  End With
Next
End Sub
Cheers

[MS MVP - Word]
 
DUDE YOU ROCK! thats exactly what i needed!

Thank You! Thank You! Thank You!





Life is not a journey to the grave with the intention
of arriving safely in a pretty and well preserved body,
but rather to skid in broadside, thoroughly used up,
totally worn out, and loudly proclaiming

--"WOW-- What a Ride!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top