View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Loop through image controls on worksheet



method 1
for i = 1 to 3
set pict = LoadPicture("C:\pic" & i & ".jpg")

next i


method 2

folder = "c:\"
PictName = array(Pic1.jpg,Pic2.jpg,Pic3.jpg)
for each picture in PictName
set pict = LoadPicture(Folder & picture)
next picture


You can set the picture properties using pict.left = .5 or any equivalent
property.
"Paul Mathews" wrote:

I'm attempting to set the picture property of several image controls on a
single worksheet (not on a user form). For example, three image controls
(named Image1, Image2, and Image3) on Sheet 1:

Sheet1.Image1.Picture = LoadPicture("C:\Pic1.jpg")
Sheet1.Image2.Picture = LoadPicture("C:\Pic2.jpg")
Sheet1.Image3.Picture = LoadPicture("C:\Pic3.jpg")

Can anyone suggest a way to set the picture property for each image by
looping rather than repeating the loadpicture for each image as above?
Thanks in advance.