PowerPoint 2007 Charts

J

JCLARK

I'm currently building custom UI in PowerPoint that links to VBA macros etc.
My questions is regarding the default charts in PowerPoint 2007.
How do you access charts and the elements of them through VBA within
PowerPoint?
I really miss the macro recorder...
 
S

Steve Rindsberg

I'm currently building custom UI in PowerPoint that links to VBA macros etc.
My questions is regarding the default charts in PowerPoint 2007.
How do you access charts and the elements of them through VBA within
PowerPoint?

This is one of those "I'm glad to have the answer but only because it means I
can stop banging my head on the desk over this" kind of answers.

You can't.

How's that for "short but not sweet"? :-(
 
J

JCLARK

Thanks Steve,
I'll have to settle with my excel vba solution.
Another question where the answer is probably the same: if I was to develop
a tool through visual studio would I then have access to the chart objects?
James
 
S

Steve Rindsberg

Another question where the answer is probably the same: if I was to develop
a tool through visual studio would I then have access to the chart objects?

I don't use VS, so can't say for sure. But when the subject's come up, I've never
heard anyone mention VS as an alternative solution; then again, I'd sure be happy
to hear it if you came back and told us it was. <g>
 
R

robert2b

Steve,

It sounds like you are sick of threads about what can and cannot be done
through VBA to modify Powerpoint 2007 charts. So I apologize ahead of time
for being so green.

VBA is relatively new to me and the threads and documentation are very
confusing. What is the purpose of the chart object in Powerpoint and the
ChartWizard, SetSourceData, ChartData,ChartTitle, ChartType and PlotBy
constructs? It there is definitive reference for their use?

Some of my confusion also arises because if you check the chart data for the
chart output created by the following Excel macro code, you will find that
cells A2 and B2 are changed on the fly. I recognize this may be trivial, but
how would I access the chart title, axis and other constructs in analogous
manner?

Sub ExcelToNewPowerPoint2()

Dim objPPT As PowerPoint.Application
Dim objPres As PowerPoint.Presentation
Dim objSlide As PowerPoint.Slide
Dim objCustomLayout As PowerPoint.CustomLayout
Dim objShape As PowerPoint.Shape
Dim strText As String

Set objPPT = CreateObject("Powerpoint.Application")
Set objPres = objPPT.Presentations.Add
Set objCustomLayout = objPres.SlideMaster.CustomLayouts.Item(1)

Set objSlide = objPres.Slides.AddSlide(1, objCustomLayout)

objSlide.Layout = PowerPoint.PpSlideLayout.ppLayoutText

Set MSChart1 = objPres.Slides(1).Shapes.AddChart(xlXYScatterLines, 100, 100,
500, 400)

'Change the contents of the data used by the PowerPoint Chart

ActiveWorkbook.Sheets("Sheet1").Range("A2") = 23
ActiveWorkbook.Sheets("Sheet1").Range("A1").Activate
ActiveCell.Offset(1, 1).FormulaR1C1 = "=[ExcelPPT.xlsm]Sheet5!RC[1]"
ActiveWindow.Close

End Sub
-------------------------------------------------
 
S

Steve Rindsberg

Steve,

It sounds like you are sick of threads about what can and cannot be done
through VBA to modify Powerpoint 2007 charts. So I apologize ahead of time
for being so green.

Thanks for saying so, but no need to apologize in advance. Really, I'm sick of
Stupid Software Tricks, not questions from users who are the victims of the SSTs.

And MS' releasing Office with charts in their current state certainly deserves the
SST label.
VBA is relatively new to me and the threads and documentation are very
confusing. What is the purpose of the chart object in Powerpoint and the
ChartWizard, SetSourceData, ChartData,ChartTitle, ChartType and PlotBy
constructs? It there is definitive reference for their use?

Sounds like you've been poking around in the object browser. ;-)
There's quite a bit of stuff in there that makes ya go "AHA! That's just what I'm
looking for." But then you find that the top-level object isn't implemented.
There's where you want to be, but you can't get there from here.

I suspect a lot of the under-the-hood work is incomplete, so MS decided not to
expose it yet. My guess? Not until the next version of Office. I hope I'm
wrong.
Some of my confusion also arises because if you check the chart data for the
chart output created by the following Excel macro code, you will find that
cells A2 and B2 are changed on the fly. I recognize this may be trivial, but
how would I access the chart title, axis and other constructs in analogous
manner?

In Excel, try the Macro Recorder (though it seems that's pretty well trashed when
it comes to charts too ... sigh).

Sub ExcelToNewPowerPoint2()

Dim objPPT As PowerPoint.Application
Dim objPres As PowerPoint.Presentation
Dim objSlide As PowerPoint.Slide
Dim objCustomLayout As PowerPoint.CustomLayout
Dim objShape As PowerPoint.Shape
Dim strText As String

Set objPPT = CreateObject("Powerpoint.Application")
Set objPres = objPPT.Presentations.Add
Set objCustomLayout = objPres.SlideMaster.CustomLayouts.Item(1)

Set objSlide = objPres.Slides.AddSlide(1, objCustomLayout)

objSlide.Layout = PowerPoint.PpSlideLayout.ppLayoutText

Set MSChart1 = objPres.Slides(1).Shapes.AddChart(xlXYScatterLines, 100, 100,
500, 400)

'Change the contents of the data used by the PowerPoint Chart

ActiveWorkbook.Sheets("Sheet1").Range("A2") = 23
ActiveWorkbook.Sheets("Sheet1").Range("A1").Activate
ActiveCell.Offset(1, 1).FormulaR1C1 = "=[ExcelPPT.xlsm]Sheet5!RC[1]"
ActiveWindow.Close

End Sub
-------------------------------------------------
Steve Rindsberg said:
This is one of those "I'm glad to have the answer but only because it means I
can stop banging my head on the desk over this" kind of answers.

You can't.

How's that for "short but not sweet"? :-(

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
W

wschiro

If you are using PowerPoint 2007 you might want to use OpenXML to create your
charts. http://openxmldeveloper.com/ Sorry, I can't be of more help. I am
looking into this myself so I can dynamically create Excel charts in
PowerPoint.

Steve Rindsberg said:
Steve,

It sounds like you are sick of threads about what can and cannot be done
through VBA to modify Powerpoint 2007 charts. So I apologize ahead of time
for being so green.

Thanks for saying so, but no need to apologize in advance. Really, I'm sick of
Stupid Software Tricks, not questions from users who are the victims of the SSTs.

And MS' releasing Office with charts in their current state certainly deserves the
SST label.
VBA is relatively new to me and the threads and documentation are very
confusing. What is the purpose of the chart object in Powerpoint and the
ChartWizard, SetSourceData, ChartData,ChartTitle, ChartType and PlotBy
constructs? It there is definitive reference for their use?

Sounds like you've been poking around in the object browser. ;-)
There's quite a bit of stuff in there that makes ya go "AHA! That's just what I'm
looking for." But then you find that the top-level object isn't implemented.
There's where you want to be, but you can't get there from here.

I suspect a lot of the under-the-hood work is incomplete, so MS decided not to
expose it yet. My guess? Not until the next version of Office. I hope I'm
wrong.
Some of my confusion also arises because if you check the chart data for the
chart output created by the following Excel macro code, you will find that
cells A2 and B2 are changed on the fly. I recognize this may be trivial, but
how would I access the chart title, axis and other constructs in analogous
manner?

In Excel, try the Macro Recorder (though it seems that's pretty well trashed when
it comes to charts too ... sigh).

Sub ExcelToNewPowerPoint2()

Dim objPPT As PowerPoint.Application
Dim objPres As PowerPoint.Presentation
Dim objSlide As PowerPoint.Slide
Dim objCustomLayout As PowerPoint.CustomLayout
Dim objShape As PowerPoint.Shape
Dim strText As String

Set objPPT = CreateObject("Powerpoint.Application")
Set objPres = objPPT.Presentations.Add
Set objCustomLayout = objPres.SlideMaster.CustomLayouts.Item(1)

Set objSlide = objPres.Slides.AddSlide(1, objCustomLayout)

objSlide.Layout = PowerPoint.PpSlideLayout.ppLayoutText

Set MSChart1 = objPres.Slides(1).Shapes.AddChart(xlXYScatterLines, 100, 100,
500, 400)

'Change the contents of the data used by the PowerPoint Chart

ActiveWorkbook.Sheets("Sheet1").Range("A2") = 23
ActiveWorkbook.Sheets("Sheet1").Range("A1").Activate
ActiveCell.Offset(1, 1).FormulaR1C1 = "=[ExcelPPT.xlsm]Sheet5!RC[1]"
ActiveWindow.Close

End Sub
-------------------------------------------------
Steve Rindsberg said:
I'm currently building custom UI in PowerPoint that links to VBA macros etc.
My questions is regarding the default charts in PowerPoint 2007.
How do you access charts and the elements of them through VBA within
PowerPoint?

This is one of those "I'm glad to have the answer but only because it means I
can stop banging my head on the desk over this" kind of answers.

You can't.

How's that for "short but not sweet"? :-(

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 

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

Top