View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Loop through image controls on worksheet

Option Explicit
Sub testme()
Dim iCtr As Long
For iCtr = 1 To 3
Sheet1.OLEObjects("Image" & iCtr).Object.Picture _
= LoadPicture("c:\pict" & iCtr & ".jpg")
Next iCtr
End Sub

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.


--

Dave Peterson