Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing what is displayed in an image control programatically

I inserted an image control into an worksheet from the Control toolbox, and I want
to be able to change the picture programmatically.

If I put "Image1.Picture = LoadPicture("C:\pictures\picture1.jpg") into the
Image1_click() event, then it loads the picture when I click the image.

However, what I have is a list of possible pictures in the worksheet (i.e.
cell A1 says "C:\pictures\picture1.jpg", A2 says "C:\pictures\picture2.jpg"
etc).

What I want is to be able to pass a variable, row_no, into a normal
subroutine (i.e. not an event procedure), so that it loads the relevant
picture into the image. But I get an error message.

This is what I have tried:

a$ = Worksheets("Data").Range("a" & row_no).text
Worksheets("Display").Shapes("Image1").Picture = LoadPicture(a$)

What am I doing wrong?

Thanks for any help

Eric Kehr
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Changing what is displayed in an image control programatically

Eric,

I was just fooling around with this. I changed two things and now it seems
to work:

Change Worksheets("Display").Shapes("Image1").Picture = LoadPicture(a$) to
Worksheets("Display").Image1.Picture = LoadPicture(a$)

and enter the filename in the cell without the double quotes. Just put a
single quote in front (the code inserts double quotes, so I was ending up
with two sets of double quotes).

I'm assuming a$ means it's declared as a string variable. If not, I think
it might need to be, but I'm not sure.

hth,

Doug Glancy

"Eric Kehr" wrote in message
om...
I inserted an image control into an worksheet from the Control toolbox,

and I want
to be able to change the picture programmatically.

If I put "Image1.Picture = LoadPicture("C:\pictures\picture1.jpg") into

the
Image1_click() event, then it loads the picture when I click the image.

However, what I have is a list of possible pictures in the worksheet (i.e.
cell A1 says "C:\pictures\picture1.jpg", A2 says

"C:\pictures\picture2.jpg"
etc).

What I want is to be able to pass a variable, row_no, into a normal
subroutine (i.e. not an event procedure), so that it loads the relevant
picture into the image. But I get an error message.

This is what I have tried:

a$ = Worksheets("Data").Range("a" & row_no).text
Worksheets("Display").Shapes("Image1").Picture = LoadPicture(a$)

What am I doing wrong?

Thanks for any help

Eric Kehr



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing what is displayed in an image control programatically





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Image not displayed when the physical file is N/A Kevin Chong Excel Discussion (Misc queries) 0 November 17th 09 09:19 AM
Changing font color of protected cells programatically Nigel Excel Discussion (Misc queries) 6 September 13th 08 12:32 PM
How to programatically control a 3D-sum? Ake Excel Worksheet Functions 6 February 2nd 06 09:20 AM
Trouble with Image Control on a worksheet MChrist Excel Worksheet Functions 0 August 19th 05 01:18 PM
Click on Image Control disables it Wexler Excel Programming 0 October 7th 03 05:35 PM


All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"