how to load pictures to image boxes in excel with a command button

G

Guest

i have afolder with picture files xxxx.jpg where xxxx is a number 0001-9999.
i want to load this files with just one click(command button) in a worksheet
in an exact position x,y (x stable , and y 4cm down for every picture)from
the beginning of the axis
im looking forward to hearing from you

im using office 2002
 
N

NickHK

Do you actually want/need to use Image controls as you subject says, or put
the images on the worksheet, as you text says ?

For the latter, recod a macro, whilst you insert 1 picture, then look to
making a loop of that code.
Having a workbook with 1000's of graphics will make for a large, slow file.

NickHK
 
G

Guest

Well i want those pictures with certain dimensions (2x2 cm) for printing id's
if they are just opened then they are too large to fit the specified
dimensions so i believe its better to be loaded in an image box (better
idea???)So i need a method to create a numerous boxes in an exact position
(1st 1cm from top 5cm from left, 2nd 13cm (1+12) from top 5cm from left, 3rd
25cm(13+12) from top 5cm from left etc) with exact dimensions to fit the
loaded picture.
I agree that i will create a large file ,but what can i do for this?
 
N

NickHK

Depending on exactly what you want, adapt this code:

Private Sub CommandButton1_Click()
Dim pic As Picture
Dim i As Long

Const MAXPICS As Long = 10
Const PICOFFSET As Long = 100

For i = 1 To MAXPICS
Set pic = ActiveSheet.Pictures.Insert("C:\Test.bmp")
With pic
.Top = i * PICOFFSET
.Left = 10
.Width = 200
.Height = 200
End With
Next

End Sub

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top