PC Review Forums Newsgroups Microsoft Excel Microsoft Excel Charting How can I change size of the picture without changing chartobject?

Reply

How can I change size of the picture without changing chartobject?

 
Thread Tools Rate Thread
Old 05-12-2004, 02:12 PM   #1
Marie J-son
Guest
 
Posts: n/a
Default How can I change size of the picture without changing chartobject?


Hi there,

I have this code in a userform and get with it a picture in the same size as
the chartobject - to small. I want a much larger (fill the screen as much as
possible). I can easily solve it by changing size of the chartobject before
export to gif, but i dno't want to do that. I want to change the size of the
gif during or after importing it by LoadPicture.

How?

Help = Forever happy

/Regards

Dim ChartNum As Integer

Private Sub UserForm_Initialize()
Debug.Print "frmPPT initilize "
ChartNum = 1
UpdateChart
End Sub

Private Sub UpdateChart()
Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart

' 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


  Reply With Quote
Old 05-12-2004, 05:50 PM   #2
Jon Peltier
Guest
 
Posts: n/a
Default Re: How can I change size of the picture without changing chartobject?

Hi Marie -

After this line, resize the Plot Area:

Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart

like this:

With CurrentChart.PlotArea
.Left = 0
.Top = 0
.Width = CurrentChart.ChartArea.Width
.Height = CurrentChart.ChartArea.Height
End With

You may need to adjust slightly, to allow room for the legend, chart title, or axis
titles.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Marie J-son wrote:

> Hi there,
>
> I have this code in a userform and get with it a picture in the same size as
> the chartobject - to small. I want a much larger (fill the screen as much as
> possible). I can easily solve it by changing size of the chartobject before
> export to gif, but i dno't want to do that. I want to change the size of the
> gif during or after importing it by LoadPicture.
>
> How?
>
> Help = Forever happy
>
> /Regards
>
> Dim ChartNum As Integer
>
> Private Sub UserForm_Initialize()
> Debug.Print "frmPPT initilize "
> ChartNum = 1
> UpdateChart
> End Sub
>
> Private Sub UpdateChart()
> Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>
> ' 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
>
>


  Reply With Quote
Old 05-12-2004, 08:35 PM   #3
Marie J-son
Guest
 
Posts: n/a
Default Right answer to wrong question, I refrase the question

Hi,

I'm awfully sorry, I should have been better explaining my question. It is
more of a userform question than a chart question - maybe. The code i showed
is lokated in the userform code and the userform is a kind of "chart
viewer" to show charts in the userform as picture. I have some buttons in
the userform etc to move between the charts, but didn't mess my question
with that.

The other option I'm thinking of is using a empty chart fullsize chartarea
or a worksheet with a chartobject filling the whole / most of the cells in
the view.

Please Jon, or any other - feel free to give answers to any of the choices
above., as long as it is a code proven to work well...

Kind regards

"Jon Peltier" <jonREMOVExlmvp@peltierCAPStech.com> skrev i meddelandet
news:OSVveLv2EHA.304@TK2MSFTNGP11.phx.gbl...
> Hi Marie -
>
> After this line, resize the Plot Area:
>
> Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>
> like this:
>
> With CurrentChart.PlotArea
> .Left = 0
> .Top = 0
> .Width = CurrentChart.ChartArea.Width
> .Height = CurrentChart.ChartArea.Height
> End With
>
> You may need to adjust slightly, to allow room for the legend, chart
> title, or axis titles.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Peltier Technical Services
> Tutorials and Custom Solutions
> http://PeltierTech.com/
> _______
>
> Marie J-son wrote:
>
>> Hi there,
>>
>> I have this code in a userform and get with it a picture in the same size
>> as the chartobject - to small. I want a much larger (fill the screen as
>> much as possible). I can easily solve it by changing size of the
>> chartobject before export to gif, but i dno't want to do that. I want to
>> change the size of the gif during or after importing it by LoadPicture.
>>
>> How?
>>
>> Help = Forever happy
>>
>> /Regards
>>
>> Dim ChartNum As Integer
>>
>> Private Sub UserForm_Initialize()
>> Debug.Print "frmPPT initilize "
>> ChartNum = 1
>> UpdateChart
>> End Sub
>>
>> Private Sub UpdateChart()
>> Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>>
>> ' 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

>



  Reply With Quote
Old 05-12-2004, 08:58 PM   #4
Jon Peltier
Guest
 
Posts: n/a
Default Re: Right answer to wrong question, I refrase the question

Hi Marie -

Gotcha. You need to use a different technique to put the chart onto the userform.
Stephen Bullen shows how to do this by copying the chart as a picture (not bitmap)
and pasting the clipboard contents into the userform's image control:

http://oaltd.co.uk/DLCount/DLCount....astePicture.zip

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

Marie J-son wrote:

> Hi,
>
> I'm awfully sorry, I should have been better explaining my question. It is
> more of a userform question than a chart question - maybe. The code i showed
> is lokated in the userform code and the userform is a kind of "chart
> viewer" to show charts in the userform as picture. I have some buttons in
> the userform etc to move between the charts, but didn't mess my question
> with that.
>
> The other option I'm thinking of is using a empty chart fullsize chartarea
> or a worksheet with a chartobject filling the whole / most of the cells in
> the view.
>
> Please Jon, or any other - feel free to give answers to any of the choices
> above., as long as it is a code proven to work well...
>
> Kind regards
>
> "Jon Peltier" <jonREMOVExlmvp@peltierCAPStech.com> skrev i meddelandet
> news:OSVveLv2EHA.304@TK2MSFTNGP11.phx.gbl...
>
>>Hi Marie -
>>
>>After this line, resize the Plot Area:
>>
>>Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>>
>>like this:
>>
>>With CurrentChart.PlotArea
>> .Left = 0
>> .Top = 0
>> .Width = CurrentChart.ChartArea.Width
>> .Height = CurrentChart.ChartArea.Height
>>End With
>>
>>You may need to adjust slightly, to allow room for the legend, chart
>>title, or axis titles.
>>
>>- Jon
>>-------
>>Jon Peltier, Microsoft Excel MVP
>>Peltier Technical Services
>>Tutorials and Custom Solutions
>>http://PeltierTech.com/
>>_______
>>
>>Marie J-son wrote:
>>
>>
>>>Hi there,
>>>
>>>I have this code in a userform and get with it a picture in the same size
>>>as the chartobject - to small. I want a much larger (fill the screen as
>>>much as possible). I can easily solve it by changing size of the
>>>chartobject before export to gif, but i dno't want to do that. I want to
>>>change the size of the gif during or after importing it by LoadPicture.
>>>
>>>How?
>>>
>>>Help = Forever happy
>>>
>>>/Regards
>>>
>>>Dim ChartNum As Integer
>>>
>>>Private Sub UserForm_Initialize()
>>>Debug.Print "frmPPT initilize "
>>> ChartNum = 1
>>> UpdateChart
>>>End Sub
>>>
>>>Private Sub UpdateChart()
>>>Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>>>
>>> ' 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

>>

>
>


  Reply With Quote
Old 05-12-2004, 11:36 PM   #5
Marie J-son
Guest
 
Posts: n/a
Default Re: Right answer to wrong question, I refrase the question

Thanks, i'll look into that.

Regards


"Jon Peltier" <jonREMOVExlmvp@peltierCAPStech.com> skrev i meddelandet
news:%23G$Y80w2EHA.1124@tk2msftngp13.phx.gbl...
> Hi Marie -
>
> Gotcha. You need to use a different technique to put the chart onto the
> userform. Stephen Bullen shows how to do this by copying the chart as a
> picture (not bitmap) and pasting the clipboard contents into the
> userform's image control:
>
> http://oaltd.co.uk/DLCount/DLCount....astePicture.zip
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Peltier Technical Services
> Tutorials and Custom Solutions
> http://PeltierTech.com/
> _______
>
> Marie J-son wrote:
>
>> Hi,
>>
>> I'm awfully sorry, I should have been better explaining my question. It
>> is more of a userform question than a chart question - maybe. The code i
>> showed is lokated in the userform code and the userform is a kind of
>> "chart viewer" to show charts in the userform as picture. I have some
>> buttons in the userform etc to move between the charts, but didn't mess
>> my question with that.
>>
>> The other option I'm thinking of is using a empty chart fullsize
>> chartarea or a worksheet with a chartobject filling the whole / most of
>> the cells in the view.
>>
>> Please Jon, or any other - feel free to give answers to any of the
>> choices above., as long as it is a code proven to work well...
>>
>> Kind regards
>>
>> "Jon Peltier" <jonREMOVExlmvp@peltierCAPStech.com> skrev i meddelandet
>> news:OSVveLv2EHA.304@TK2MSFTNGP11.phx.gbl...
>>
>>>Hi Marie -
>>>
>>>After this line, resize the Plot Area:
>>>
>>>Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>>>
>>>like this:
>>>
>>>With CurrentChart.PlotArea
>>> .Left = 0
>>> .Top = 0
>>> .Width = CurrentChart.ChartArea.Width
>>> .Height = CurrentChart.ChartArea.Height
>>>End With
>>>
>>>You may need to adjust slightly, to allow room for the legend, chart
>>>title, or axis titles.
>>>
>>>- Jon
>>>-------
>>>Jon Peltier, Microsoft Excel MVP
>>>Peltier Technical Services
>>>Tutorials and Custom Solutions
>>>http://PeltierTech.com/
>>>_______
>>>
>>>Marie J-son wrote:
>>>
>>>
>>>>Hi there,
>>>>
>>>>I have this code in a userform and get with it a picture in the same
>>>>size as the chartobject - to small. I want a much larger (fill the
>>>>screen as much as possible). I can easily solve it by changing size of
>>>>the chartobject before export to gif, but i dno't want to do that. I
>>>>want to change the size of the gif during or after importing it by
>>>>LoadPicture.
>>>>
>>>>How?
>>>>
>>>>Help = Forever happy
>>>>
>>>>/Regards
>>>>
>>>>Dim ChartNum As Integer
>>>>
>>>>Private Sub UserForm_Initialize()
>>>>Debug.Print "frmPPT initilize "
>>>> ChartNum = 1
>>>> UpdateChart
>>>>End Sub
>>>>
>>>>Private Sub UpdateChart()
>>>>Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>>>>
>>>> ' 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
>>>

>>
>>

>



  Reply With Quote
Old 06-12-2004, 05:46 PM   #6
Tushar Mehta
Guest
 
Posts: n/a
Default Re: Right answer to wrong question, I refrase the question

Have you tried adjusting the userform control's PictureSizeMode
property? There are three possibilities and the value
fmPictureSizeModeZoom (or maybe fmPictureSizeModeStretch) should do the
job.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article <O48Iumw2EHA.2876@TK2MSFTNGP12.phx.gbl>, Not@email.com
says...
> Hi,
>
> I'm awfully sorry, I should have been better explaining my question. It is
> more of a userform question than a chart question - maybe. The code i showed
> is lokated in the userform code and the userform is a kind of "chart
> viewer" to show charts in the userform as picture. I have some buttons in
> the userform etc to move between the charts, but didn't mess my question
> with that.
>
> The other option I'm thinking of is using a empty chart fullsize chartarea
> or a worksheet with a chartobject filling the whole / most of the cells in
> the view.
>
> Please Jon, or any other - feel free to give answers to any of the choices
> above., as long as it is a code proven to work well...
>
> Kind regards
>
> "Jon Peltier" <jonREMOVExlmvp@peltierCAPStech.com> skrev i meddelandet
> news:OSVveLv2EHA.304@TK2MSFTNGP11.phx.gbl...
> > Hi Marie -
> >
> > After this line, resize the Plot Area:
> >
> > Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
> >
> > like this:
> >
> > With CurrentChart.PlotArea
> > .Left = 0
> > .Top = 0
> > .Width = CurrentChart.ChartArea.Width
> > .Height = CurrentChart.ChartArea.Height
> > End With
> >
> > You may need to adjust slightly, to allow room for the legend, chart
> > title, or axis titles.
> >
> > - Jon
> > -------
> > Jon Peltier, Microsoft Excel MVP
> > Peltier Technical Services
> > Tutorials and Custom Solutions
> > http://PeltierTech.com/
> > _______
> >
> > Marie J-son wrote:
> >
> >> Hi there,
> >>
> >> I have this code in a userform and get with it a picture in the same size
> >> as the chartobject - to small. I want a much larger (fill the screen as
> >> much as possible). I can easily solve it by changing size of the
> >> chartobject before export to gif, but i dno't want to do that. I want to
> >> change the size of the gif during or after importing it by LoadPicture.
> >>
> >> How?
> >>
> >> Help = Forever happy
> >>
> >> /Regards
> >>
> >> Dim ChartNum As Integer
> >>
> >> Private Sub UserForm_Initialize()
> >> Debug.Print "frmPPT initilize "
> >> ChartNum = 1
> >> UpdateChart
> >> End Sub
> >>
> >> Private Sub UpdateChart()
> >> Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
> >>
> >> ' 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

> >

>
>
>

  Reply With Quote
Old 07-12-2004, 12:34 PM   #7
Marie J-son
Guest
 
Posts: n/a
Default Re: Right answer to wrong question, I refrase the question

Yes, but strech make an awful mess of the chart, even as narrow you try to
get ratio fixed.
Mode does the job, but I find the GIF become lousy quality as well. If you
save the chart in the same size as you later want in GIF, the quality will
be fine.

If I try to copy and paste a chart first and enlarger the new chart and then
delete it make good pictures, but I find Excel to slow to copy paste a
chartobject, even if you of course use screenupdating = false.

/Regards


"Tushar Mehta" <tmUnderscore200310@tushar-mehta.SeeOhEm> skrev i meddelandet
news:MPG.1c1e651f506d85f9899f4@news-server.rochester.rr.com...
> Have you tried adjusting the userform control's PictureSizeMode
> property? There are three possibilities and the value
> fmPictureSizeModeZoom (or maybe fmPictureSizeModeStretch) should do the
> job.
>
> --
> Regards,
>
> Tushar Mehta
> www.tushar-mehta.com
> Excel, PowerPoint, and VBA add-ins, tutorials
> Custom MS Office productivity solutions
>
> In article <O48Iumw2EHA.2876@TK2MSFTNGP12.phx.gbl>, Not@email.com
> says...
>> Hi,
>>
>> I'm awfully sorry, I should have been better explaining my question. It
>> is
>> more of a userform question than a chart question - maybe. The code i
>> showed
>> is lokated in the userform code and the userform is a kind of "chart
>> viewer" to show charts in the userform as picture. I have some buttons in
>> the userform etc to move between the charts, but didn't mess my question
>> with that.
>>
>> The other option I'm thinking of is using a empty chart fullsize
>> chartarea
>> or a worksheet with a chartobject filling the whole / most of the cells
>> in
>> the view.
>>
>> Please Jon, or any other - feel free to give answers to any of the
>> choices
>> above., as long as it is a code proven to work well...
>>
>> Kind regards
>>
>> "Jon Peltier" <jonREMOVExlmvp@peltierCAPStech.com> skrev i meddelandet
>> news:OSVveLv2EHA.304@TK2MSFTNGP11.phx.gbl...
>> > Hi Marie -
>> >
>> > After this line, resize the Plot Area:
>> >
>> > Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>> >
>> > like this:
>> >
>> > With CurrentChart.PlotArea
>> > .Left = 0
>> > .Top = 0
>> > .Width = CurrentChart.ChartArea.Width
>> > .Height = CurrentChart.ChartArea.Height
>> > End With
>> >
>> > You may need to adjust slightly, to allow room for the legend, chart
>> > title, or axis titles.
>> >
>> > - Jon
>> > -------
>> > Jon Peltier, Microsoft Excel MVP
>> > Peltier Technical Services
>> > Tutorials and Custom Solutions
>> > http://PeltierTech.com/
>> > _______
>> >
>> > Marie J-son wrote:
>> >
>> >> Hi there,
>> >>
>> >> I have this code in a userform and get with it a picture in the same
>> >> size
>> >> as the chartobject - to small. I want a much larger (fill the screen
>> >> as
>> >> much as possible). I can easily solve it by changing size of the
>> >> chartobject before export to gif, but i dno't want to do that. I want
>> >> to
>> >> change the size of the gif during or after importing it by
>> >> LoadPicture.
>> >>
>> >> How?
>> >>
>> >> Help = Forever happy
>> >>
>> >> /Regards
>> >>
>> >> Dim ChartNum As Integer
>> >>
>> >> Private Sub UserForm_Initialize()
>> >> Debug.Print "frmPPT initilize "
>> >> ChartNum = 1
>> >> UpdateChart
>> >> End Sub
>> >>
>> >> Private Sub UpdateChart()
>> >> Set CurrentChart = Blad102.ChartObjects(ChartNum).Chart
>> >>
>> >> ' 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
>> >

>>
>>
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off