Hello. Office 2003.
I want to open a presentation using code and change the source data for a chart.
Does anyone know the instruction that will give me access to a chart's Datasheet? Thanks, Andy.
Change PowerPoint data
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Change PowerPoint data
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Change PowerPoint data
Do you want to do this from Access? (You posted this question in the Access/SQL forum)
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Change PowerPoint data
Hello. Yes, I want to do this from Access.
Actually, I've found a sample procedure and I can see that I need to obtain a reference to the M/S Graph object to change the data.
Thanks anyway. I'll try this tomorrow. Andy.
Actually, I've found a sample procedure and I can see that I need to obtain a reference to the M/S Graph object to change the data.
Thanks anyway. I'll try this tomorrow. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Change PowerPoint data
Hello. I've borrowed the following code and have references to the PowerPoint and Microsoft Graph applications.
Dim myPP As PowerPoint.Application
Dim pptShape As PowerPoint.Shape
Dim pptPres As PowerPoint.Presentation
Dim myGraph As Graph.Chart
Dim strPresPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim x As Integer
Set myPP = CreateObject("PowerPoint.Application")
myPP.Visible = msoTrue
strPresPath = "C:\Documents and Settings\mouse\My Documents"
Set pptPres = myPP.Presentations.Open(strPresPath & "\My Presentation.ppt")
Set pptShape = pptPres.Slides(2).Shapes(1)
Set myGraph = pptShape.OLEFormat.Object
But it fails at the last line -OLE Format - Unknown Member..
I inserted a 'Title and Chart' slide for this purpose.
How can I resolve this please? Thanks, Andy.
Dim myPP As PowerPoint.Application
Dim pptShape As PowerPoint.Shape
Dim pptPres As PowerPoint.Presentation
Dim myGraph As Graph.Chart
Dim strPresPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim x As Integer
Set myPP = CreateObject("PowerPoint.Application")
myPP.Visible = msoTrue
strPresPath = "C:\Documents and Settings\mouse\My Documents"
Set pptPres = myPP.Presentations.Open(strPresPath & "\My Presentation.ppt")
Set pptShape = pptPres.Slides(2).Shapes(1)
Set myGraph = pptShape.OLEFormat.Object
But it fails at the last line -OLE Format - Unknown Member..
I inserted a 'Title and Chart' slide for this purpose.
How can I resolve this please? Thanks, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Change PowerPoint data
In the first place, you should use Shapes(2), for Shapes(1) will be the title box of the slide.
In the second place, try
Set myGraph = pptShape.Chart
In the second place, try
Set myGraph = pptShape.Chart
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Change PowerPoint data
Hello.
Set myGraph = pptShape.Chart yields 'Method or Data Member not found'? Andy.
Set myGraph = pptShape.Chart yields 'Method or Data Member not found'? Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78608
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Change PowerPoint data
Hmmm. I'm using Office 2007. The PowerPoint object model has changed a lot between the 2003 and 2007 versions, so it's quite possible that Chart is not a valid property in PowerPoint 2003 VBA.
Hopefully someone who has Office 2003 will be able to tell you how to do this.
Hopefully someone who has Office 2003 will be able to tell you how to do this.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Change PowerPoint data
Hello.
Actually it works if I retain the OLEFormat.Object reference. Thanks Andy.
Actually it works if I retain the OLEFormat.Object reference. Thanks Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.