ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   for i...next i over images in a sheet (https://www.excelbanter.com/excel-programming/366671-i-next-i-over-images-sheet.html)

furbiuzzu

for i...next i over images in a sheet
 
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.


Tom Ogilvy

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.




furbiuzzu

for i...next i over images in a sheet
 

Tom Ogilvy ha scritto:

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



thanks a lot !!!

i'll try it as soon as possible, now i'm not at home.

but i've encountered another problem in the command

Loadpicture(path)

the variable path as you can see is related with a cell where i merge
the "s before and after the "real" path.... do you think i'll encounter
the same problem with your code lines?


Tom Ogilvy

for i...next i over images in a sheet
 
My code didn't alter any other part of what you posted, so it should behave
no differently.

You shouldn't be adding double quotes around the path string.

spath = Activecell.Value

not
spath = """" & ActiveCell.Value & """"

--
Regards,
Tom Ogilvy

"furbiuzzu" wrote in message
ups.com...

Tom Ogilvy ha scritto:

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



thanks a lot !!!

i'll try it as soon as possible, now i'm not at home.

but i've encountered another problem in the command

Loadpicture(path)

the variable path as you can see is related with a cell where i merge
the "s before and after the "real" path.... do you think i'll encounter
the same problem with your code lines?




furbiuzzu

for i...next i over images in a sheet
 

Tom Ogilvy ha scritto:

My code didn't alter any other part of what you posted, so it should behave
no differently.

You shouldn't be adding double quotes around the path string.

spath = Activecell.Value

not
spath = """" & ActiveCell.Value & """"

--
Regards,
Tom Ogilvy


problem solved!
thanks again!

regards,
Fulvio Salvo



All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com