Do you really need to use Image controls (which it sounds like in your
description) ?
If you can just put the graphics on the worksheet, here are 2 methods below.
If you need to use image controls, post back.
The first method uses the more up-to-date Shapes collection, whilst the 2nd
uses the older Pictures collection.
Both are valid. Depends what you want to do with the graphics after.
Private Sub CommandButton3_Click()
Dim PicNames As Variant
Dim WS As Worksheet
Dim Pic As Picture
Dim i As Long
'Note the MultiSelect=True
PicNames = Application.GetOpenFilename("JPG Files (*.jpg), *.jpg", , , ,
True)
If Not IsArray(PicNames) Then Exit Sub
'Set to the required destination
Set WS = Worksheets(1)
For i = LBound(PicNames) To UBound(PicNames)
WS.Shapes.AddPicture PicNames(i), msoFalse, msoTrue, 10, 10 + 10 * i,
100, 100
Next
'Or
'To reduce flicker when resizing
Application.ScreenUpdating = False
For i = LBound(PicNames) To UBound(PicNames)
Set Pic = ActiveSheet.Pictures.Insert(PicNames(i))
With Pic
.Left = 200
.Top = 10 + 10 * i
.Width = .Width / 2
.Height = .Height / 2
End With
Next
Application.ScreenUpdating = True
End Sub
NickHK
> Hi all,
>
[quoted text clipped - 14 lines]
>
> www.xfire.com/profile/gaioshin/
wmycheung@gmail.com - 25 Jan 2007 11:30 GMT
Hi Nick,
Thanks for your reply and code. Basically, I have a pool of images and
I want to be able to tag them, thereby toggling a flag alongside the
appropriate filename stored in a worksheet - for example, for three
items of dog.jpg, cat.jpg and chinchilla.jpg, there would be a column
with their names in plus the adjacent column. A form would then load
the thumbnails into a frame, and then the user upon clicking on the
thumbnail of the dog, will be able to see a "CLICKED" in the cell in
the column adjacent to the cell containing dog.jpg.
I'll give the code a try in a moment and see where I fall over next!
Regards,
Gaioshin
> Do you really need to use Image controls (which it sounds like in your
> description) ?
[quoted text clipped - 62 lines]
>
> >www.xfire.com/profile/gaioshin/- Hide quoted text -- Show quoted text -