Image Control Question

K

kirkm

I have an image control on a Form and it's picture property is set
at design time.

This picture property is later changed by the command :

Form1.image1.Picture = Form2.Controls(k).Picture (k is set
appropriately).

What command sytax would be used to later restore Form1.image1.Picture
to it's design time default?

The Form is not closed whilst these images are changing, which may be
a solution, but preferably not if there's any alternative.

Thanks - Kirk
 
P

Peter T

You'd need to store the original image so you can reset it.

I'd approach it like this, add an additional image control (ImgDefault) and
assign it's picture to that of your default image. Do NOT assign a picture
to your Image1 at design. In the form's initialize event do

Form1.image1.Picture = Form2.Controls("ImgDefault").Picture
Unload Form2 ' possibly ?

While your form is loaded, whenever you want to reapply the default image
run the above again (no doubt you can change "ImgDefault" to an index 'k').

Regards,
Peter T
 
R

Rick Rothstein

Put this statement in the (General)(Declarations) section of the UserForm's
code window...

Dim OriginalPicture As StdPicture

Then put this in the UserForm's Initialize event...

Set OriginalPicture = Image1.Picture

Now, whenever and wherever you want to restore the original picture for the
Image1 control, just execute this statement...

Set Image1.Picture = OriginalPicture
 
K

kirkm

Put this statement in the (General)(Declarations) section of the UserForm's
code window...

Dim OriginalPicture As StdPicture

Then put this in the UserForm's Initialize event...

Set OriginalPicture = Image1.Picture

Now, whenever and wherever you want to restore the original picture for the
Image1 control, just execute this statement...

Set Image1.Picture = OriginalPicture

Thanks Guys, I've spent quite a long time trying to achieve this and
have concluded it's just not worth it ! The 'Set" command seems to
cause Excel to crash with that 'Sorry for the inconvieniance' thing.
Then it spends hours recovering....

The simplist fix is not have any default image and create the required
one each time. Problem gone.

My original theory seemed Ok: if the image exists, use it
otherwise use the default - but too much hassle !

Thanks for the suggestions and help though.
Cheers - Kirk
 
R

Rick Rothstein

Just so you are aware, I tested the code before I posted it and it worked
fine here on my XL2003 system. If you are getting a crash, then something
other than the Set statement is causing it.
 
K

kirkm

Just so you are aware, I tested the code before I posted it and it worked
fine here on my XL2003 system. If you are getting a crash, then something
other than the Set statement is causing it.

Sorry Rick, I never meant there was anything wrong with your code, it
was just threading it in with what's here.... I'm a learner and what
I'm doing is really way too ambitious. A million things could upset it
- BUT it's stable and working at the moment :)
Thanks agan for the help.... what I've got from this group is
invaluable.

Cheers - Kirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top