ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   paste 2 charts on the same image on a userform (https://www.excelbanter.com/excel-programming/433632-paste-2-charts-same-image-userform.html)

Valeria

paste 2 charts on the same image on a userform
 
Dear experts,
I am using John Walkenbach's code to show charts as images on a userform. I
have added some buttons where users can choose which charts they want to see,
however for one particular type I would like to put 2 charts on the same
image, one next to the other (it is 2 thermometer charts). Is this possible?

Here is the code I am using (I am adapting the size of the image to the
userform.image1 as I have made the userform resizable)

Private Sub UpdateChart()
Set CurrentChart = Sheets("Charts2").ChartObjects(ChartNum).Chart
CurrentChart.Parent.Width = Image1.Width
CurrentChart.Parent.Height = Image1.Height

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"

' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub


Many thanks in advance for your help!
Kind regards,

--
Valeria

Bob Phillips[_3_]

paste 2 charts on the same image on a userform
 
I think that your simplest option would be to have two adjacent images on
the form and export and loadPicture the two charts. You could hide the
second when not needed.

--
__________________________________
HTH

Bob

"Valeria" wrote in message
...
Dear experts,
I am using John Walkenbach's code to show charts as images on a userform.
I
have added some buttons where users can choose which charts they want to
see,
however for one particular type I would like to put 2 charts on the same
image, one next to the other (it is 2 thermometer charts). Is this
possible?

Here is the code I am using (I am adapting the size of the image to the
userform.image1 as I have made the userform resizable)

Private Sub UpdateChart()
Set CurrentChart = Sheets("Charts2").ChartObjects(ChartNum).Chart
CurrentChart.Parent.Width = Image1.Width
CurrentChart.Parent.Height = Image1.Height

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"

' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub


Many thanks in advance for your help!
Kind regards,

--
Valeria




Jacob Skaria

paste 2 charts on the same image on a userform
 
Just to add on.. You could hide the second image control or resize it ..

On the other hand you can use the Chart Export option itself to copy both
charts as picture onto a new chart (resized to fit both pictures) and export
to a single file..

If this post helps click Yes
---------------
Jacob Skaria


"Bob Phillips" wrote:

I think that your simplest option would be to have two adjacent images on
the form and export and loadPicture the two charts. You could hide the
second when not needed.

--
__________________________________
HTH

Bob

"Valeria" wrote in message
...
Dear experts,
I am using John Walkenbach's code to show charts as images on a userform.
I
have added some buttons where users can choose which charts they want to
see,
however for one particular type I would like to put 2 charts on the same
image, one next to the other (it is 2 thermometer charts). Is this
possible?

Here is the code I am using (I am adapting the size of the image to the
userform.image1 as I have made the userform resizable)

Private Sub UpdateChart()
Set CurrentChart = Sheets("Charts2").ChartObjects(ChartNum).Chart
CurrentChart.Parent.Width = Image1.Width
CurrentChart.Parent.Height = Image1.Height

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"

' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub


Many thanks in advance for your help!
Kind regards,

--
Valeria






All times are GMT +1. The time now is 07:14 AM.

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