ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using pictures in Userforms (https://www.excelbanter.com/excel-programming/358673-using-pictures-userforms.html)

Ozgur Pars[_2_]

Using pictures in Userforms
 
Hi there,
until recently used Message Boxes to give the user information. However as
of right now I need to give more information and the upkeep in the current
format requires me to change the code so that the apearance is uniform.

I have tables in a seperate worksheet which I managed to turn into pictures.
I intend to load them on userforms which will pop-up after double-clicks.(The
tables will change dynamicly so copy and paste in the properties window of a
image won't work I guess)

My question is how do I load them from the worksheet into a Userform? Do I
need to export them first and then import them back? Or do I even need
Userforms in the first place can I display pictures in Msg Boxes?

Thank you,
Ozgur

Edwin Tam[_7_]

Using pictures in Userforms
 
Put this macro into a module:

Sub example()
ActiveChart.Export "temp.jpg", "JPG", True
UserForm1.Show
On Error Resume Next
Unload UserForm1
Kill "temp.jpg"
On Error GoTo 0
End Sub


Then, in your Userform (e.g. UserForm1), create an image control (e.g.
called "Image1"), and a command button called "CommandButton1"). Set the
Autosize property of the image control to true.

Place the code below into the form.

Private Sub UserForm_Activate()
Image1.Picture = LoadPicture("temp.jpg")
End Sub

Private Sub CommandButton1_Click()
Me.Hide
End Sub


With a chart selected, run the macro "example".

I also put a sample file in my web site:
http://www.vonixx.com/excel/chart_in_form.xls

Regards,
Edwin Tam

http://www.vonixx.com




"Ozgur Pars" wrote:

Hi there,
until recently used Message Boxes to give the user information. However as
of right now I need to give more information and the upkeep in the current
format requires me to change the code so that the apearance is uniform.

I have tables in a seperate worksheet which I managed to turn into pictures.
I intend to load them on userforms which will pop-up after double-clicks.(The
tables will change dynamicly so copy and paste in the properties window of a
image won't work I guess)

My question is how do I load them from the worksheet into a Userform? Do I
need to export them first and then import them back? Or do I even need
Userforms in the first place can I display pictures in Msg Boxes?

Thank you,
Ozgur


Ozgur Pars[_2_]

Using pictures in Userforms
 
Edwin thank you for your response.
I did copy your code into a module and userform and it works great with a
chart. However I was wondering if I can do the same export with a picture(I
have a range of cells saved as a picture)?
This does not work...
ActiveSheet.Shapes("Picture 1").Export "temp.jpg", "JPG", True

Any thoughts?

Thanks again for your help.

Özgür
"Edwin Tam" wrote:

Put this macro into a module:

Sub example()
ActiveChart.Export "temp.jpg", "JPG", True
UserForm1.Show
On Error Resume Next
Unload UserForm1
Kill "temp.jpg"
On Error GoTo 0
End Sub


Then, in your Userform (e.g. UserForm1), create an image control (e.g.
called "Image1"), and a command button called "CommandButton1"). Set the
Autosize property of the image control to true.

Place the code below into the form.

Private Sub UserForm_Activate()
Image1.Picture = LoadPicture("temp.jpg")
End Sub

Private Sub CommandButton1_Click()
Me.Hide
End Sub


With a chart selected, run the macro "example".

I also put a sample file in my web site:
http://www.vonixx.com/excel/chart_in_form.xls

Regards,
Edwin Tam

http://www.vonixx.com




"Ozgur Pars" wrote:

Hi there,
until recently used Message Boxes to give the user information. However as
of right now I need to give more information and the upkeep in the current
format requires me to change the code so that the apearance is uniform.

I have tables in a seperate worksheet which I managed to turn into pictures.
I intend to load them on userforms which will pop-up after double-clicks.(The
tables will change dynamicly so copy and paste in the properties window of a
image won't work I guess)

My question is how do I load them from the worksheet into a Userform? Do I
need to export them first and then import them back? Or do I even need
Userforms in the first place can I display pictures in Msg Boxes?

Thank you,
Ozgur



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

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