View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default for i...next i over images in a sheet

Dim path As String
Dim i As Integer

Sheets("team").Select
For i = 1 To 20
path = Worksheets("team").Range("GW" & i + 1).Value
Activesheet.OleObjects("image" & i).Object.picture = LoadPicture(path)
Next i
End Sub


#2
Activesheet.OleObjects("image" & i).Object.picture = loadpicture("")


--
Regards,
Tom Ogilvy


"furbiuzzu" wrote in message
ups.com...
i've 2 little problems i'm not able to solve.

i've to associate a specific picture to each images in my active sheet.
(the number of images may be variable depending on the number of
connected data).
let's say i want to associate a different picture to each of my images.

so i've created a list like that:

cell1 image1 - image1.picture= loadpicture (file1.gif)
cell2 image2 - image2.picture= loadpicture (file2.gif)
......
......
cell10 image10 - image10.picture= loadpicture (file10.gif)
......
......
cell100 image100 - image100.picture= loadpicture (file100.gif)

Question 1

i would like to write a routine with a for i... next command able to
associate the right file to each of my images...

the problem is that a routine like the following doesn't work:

Sub associate_immages()

Dim path As String
Dim i As Integer

Sheets("team").Select
For i = 1 To 20
path = Worksheets("team").Range("GW" & i + 1).Value
Activesheet."image" & i.picture = LoadPicture(path)
Next i
End Sub

i've tried also with

'Sheets("team").form("image" & i).picture = LoadPicture(path)

and

'Sheets("team").shapes("image" & i).picture = LoadPicture(path)

but again i've an error message.

how can i solve this problem??


Question 2

some of the images should not be associated with any picture leaving
the backstyle completely transparent....

how can i delete the previous picture (using the same routine as
before) leaving the image "empty" ??


thanks in advance for your help.