ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Image Control Question (https://www.excelbanter.com/excel-programming/417406-image-control-question.html)

kirkm[_7_]

Image Control Question
 
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


Peter T

Image Control Question
 
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


"kirkm" wrote in message
...
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




Rick Rothstein

Image Control Question
 
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

--
Rick (MVP - Excel)


"kirkm" wrote in message
...
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



kirkm[_7_]

Image Control Question
 
On Mon, 22 Sep 2008 10:45:55 -0400, "Rick Rothstein"
wrote:

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

Rick Rothstein

Image Control Question
 
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.

--
Rick (MVP - Excel)


"kirkm" wrote in message
...
On Mon, 22 Sep 2008 10:45:55 -0400, "Rick Rothstein"
wrote:

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



kirkm[_7_]

Image Control Question
 
On Tue, 23 Sep 2008 01:19:25 -0400, "Rick Rothstein"
wrote:

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


All times are GMT +1. The time now is 11:38 AM.

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