MS Office Forum / General PowerPoint Questions / December 2007
Importing Data From Excel into PPT Charts and Graphs using VBA
|
|
Thread rating:  |
Todd Waldron - 07 Nov 2007 19:37 GMT Hi all,
I'm running MS-Office 2003 and I have a PPT template (9 slides) that contain fixed slide objects (text boxes, charts, graphs) where I need to frequently update the data in the objects from an Excel data file using VBA.
I'm using MS-Access as the UI and COM controller; I've added the Excel and PPT library references; through VBA - I've got working instances of the applications, and successful connections to the Excel data file and the PPT template.
The snag I've run into is I'm not sure how to refer to the chart/graph objects to make updates. I've determined that the chart and graph object types in my template are "Microsoft Graph Chart". What I want to do is select a range from the Excel data file, copy, then paste the range into the datasheet behind the respective chart/graph.
I recorded a macro for a graph in PPT where I manually accessed the datasheet behind a graph object and typed in some data. I wanted to see if it would show me how to refer to the graph object. Below is what the macro wrote:
ActiveWindow.Selection.SlideRange.Shapes("Object 3").Select ActiveWindow.Selection.ShapeRange.OLEFormat.DoVerb Index:=1 ActiveWindow.Selection.Unselect
Is there a way to determine the ID, Name, or Idex of the chart/graph objects so I can call and update them? Is there an object library I can refer to for "MS Graph Chart"?
Since I'm using MS-Access as the COM controller I found and added the Microsoft Graph 11.0 Object Library (C:\Program Files\Microsoft Office\Office11\graph.exe) just in case.
Any help would be greatly appreciated!
Thank you,
Todd Waldron Austin, Texas
Brian Reilly, MVP - 08 Nov 2007 01:41 GMT It's fun for us to track multiple messages so we will ignore your repost (g) Now, the real issue is getting data from Access into PPT whether it goes though Excel or not? That is a Yes or No answer (been talking to too many lawyers lately).
Macro Recorder is a nice thing, we all use it but it is frankly weak. That said, let me ask a few questions and offer an alternative.
Q.1 Why are you using MS Graph in the first place? Q. 2 Can't you make the chart in an Excel Chart and copy and paste just the "DataSheet and Chartsheet" into PPT. I would make life easier.
If it were me doing this, and I do a lot of this, literally hundreds of thousands of PPT pages per year based on Access data.
My personal prefernces are to NEVER use MS Grump (Graph) for a variety of reasons. 1. Graphics issues are easier to handle in Excel 2. Calculations on cells work in XL and not in Grump 3. Somewhat more difficult to prgram and get programming support. XL support is HUGE.
So enough of my over reaction to using MS Grump.
Now onto, my favorite topic of the day, spent a fair amount of time on the phone today with my fellow MVP friend, Steve Rindsberg would be the name, talking about Tags in PPT
If you know tags, (if you don't look in PPT Help for more info.) Sounds like you are programming smart and will get the concept fairly quickly. Simply said, Tags would let you automatically update the data from Excel and/or Access with a single button click, or you could write a little AutoStart routine into a PPT addin that would do this.
Now, other MVP's might say to copy and paste Link as an OLE object. I don't say that approach is wrong, it is just fragile and not "bullet proof" as deveopers like to refer to coding.
Feel free to add back to this thread. I'm sure you will hear from other MVP's who agree or disagree with me. That's the fun of the Newsgroup. Open and honest. Heck, we all learn here by sharing. Echo (MVP) taught me a new thing yesterday and I am not ashamed to admit that I don't know everything. Heck, I've taught Echo a trick or two in the past. Maybe it was on Halloween when we can do Trick AND Treat.
Brian Reilly.MVP
>Hi all, > [quoted text clipped - 36 lines] >Todd Waldron >Austin, Texas Todd Waldron - 08 Nov 2007 21:28 GMT Hi Brian,
Thank you for your response. I can re-create the charts/graphs in Excel. I inherited this PPT template, whoever created it originally chose MS Graph for the charts/graphs. I'll also check out the tags you mentioned. Thanks again, I'm sure I'll be back with more questions!
Todd Waldron Austin, Texas
> It's fun for us to track multiple messages so we will ignore your > repost (g) [quoted text clipped - 86 lines] > >Todd Waldron > >Austin, Texas Todd Waldron - 14 Nov 2007 17:12 GMT Hi Brian,
Thank you again for your response. I'm open to using tags to update my charts and graphs, however I'm really short on time to complete this project and feel uneasy about trying to dive into a new concept this late in the game. Is there a way to continue by using the following approach (so I can keep things consistent)?
For example, below is a section of code that I'm using to update a text box on one of my slides:
***Code Start***
'Copy the range from the Excel data file for Slide 6 wksWorkSheet.Range("G1:G9").Copy
'Paste the range from the Excel Data file to Slide 6 appPPT.ActiveWindow.View.GotoSlide (6)
With appPPT.ActiveWindow.Selection .SlideRange.Shapes("Rectangle 3").Select .ShapeRange.TextFrame.TextRange.Select .ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=24).Select appPPT.ActiveWindow.View.PasteSpecial (ppPasteText) .ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=17).Select .TextRange.Font.Size = 16 .ShapeRange.TextFrame.TextRange.Paragraphs(Start:=1, Length:=9).ParagraphFormat.Alignment = ppAlignRight .Unselect End With
***Code End***
My approach so far has been to copy the new data from my Excel data file, then in the PPT, navigate to the corresponding slide, navigate to the corresponding slide object, access the slide object, and paste the new data.
The fixed slide object types in my presentation template include: Text Boxes Excel DataSheets (displayed) Excel Graphs (with underlying Excel DataSheet) Excel Charts (with underlying Excel DataSheet)
My only hurdle at this point is learning how to update the Excel objects.
For example, on one slide I have two different objects, an Excel DataSheet (displayed) and an Excel Graph (with underlying Excel DataSheet), both of which need to be updated. In this case how do I access the Excel objects, and how do I differentiate between the displayed Excel datasheet and the underlying datasheet for the graph? Would you be so kind as to provide an example of how you would approach this using the method I'm describing, or an example using the tags as you've described? I would be most grateful.
Thank you,
Todd Waldron Austin, Texas
> It's fun for us to track multiple messages so we will ignore your > repost (g) [quoted text clipped - 86 lines] > >Todd Waldron > >Austin, Texas Steve Rindsberg - 08 Nov 2007 01:54 GMT > I recorded a macro for a graph in PPT where I manually accessed the > datasheet behind a graph object and typed in some data. I wanted to see if [quoted text clipped - 4 lines] > ActiveWindow.Selection.ShapeRange.OLEFormat.DoVerb Index:=1 > ActiveWindow.Selection.Unselect No value there. PPT only records actions that take place IN PPT. Once you activate the graph, you're in a different application, MSGraph.
It's often helpful to record a macro in Excel instead. Much of what you get there can apply to automating MSGraph.
Have a look here for some other helpful bits:
Working with MSGraph charts http://www.pptfaq.com/index.html#name_Working_with_MSGraph_charts
> Is there a way to determine the ID, Name, or Idex of the chart/graph objects > so I can call and update them? Is there an object library I can refer to for [quoted text clipped - 10 lines] > Todd Waldron > Austin, Texas ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================
Todd Waldron - 08 Nov 2007 21:31 GMT Hi Steve,
Thank you for your response, your sites have a lot of great stuff! For this particular problem I think I'll re-create the charts/graphs in Excel so they will be easier to work with. Thanks again.
Todd Waldron Austin, Texas
> > I recorded a macro for a graph in PPT where I manually accessed the > > datasheet behind a graph object and typed in some data. I wanted to see if [quoted text clipped - 36 lines] > PPTools: www.pptools.com > ================================================ Steve Rindsberg - 09 Nov 2007 19:57 GMT > Hi Steve, > > Thank you for your response, your sites have a lot of great stuff! For this > particular problem I think I'll re-create the charts/graphs in Excel so they > will be easier to work with. Thanks again. Good choice. More flexibility, the macro recorder will actually do some useful stuff (the one in Excel, that is) and we can make Brian answer your questions. It's good to make him work for his daily crust.
> Todd Waldron > Austin, Texas [quoted text clipped - 39 lines] > > PPTools: www.pptools.com > > ================================================ ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================
avi - 17 Nov 2007 22:14 GMT Dear Todd ,
Following your interst in Excel to PowerPoint export, I am glad to announce the release of EzPaste-xl2ppt, a software aimed at completely automating the task while providing maximum flexibility. The product could improve drastically productivity
For more details please consult http://www.EzPaste.net
Comments and suggestions will be welcomed
Thanks for your attention
Avi Metrics institute
Francisco.Duque@gmail.com - 01 Dec 2007 22:04 GMT I am trying to link an excel file and a powerpoint file, so that if i change some cells in excel (let's say a number within a cell ) , the powerpoint will update with that number (eg.: "the weather on sunday was [0C]"). Note that the text (weather on sunday was) is typed in powerpoint and the only link item would be "0C".
I have noticed that this can be possible within microsoft word (paste special -> Paste Link -> Unformatted text) but this option is not available within Powerpoint.
does anyone have a solution?
many thank in advance
Steve Rindsberg - 02 Dec 2007 19:46 GMT > I am trying to link an excel file and a powerpoint file, so that if i > change some cells in excel (let's say a number within a cell ) , the [quoted text clipped - 5 lines] > special -> Paste Link -> Unformatted text) but this option is not > available within Powerpoint. What options are you offered when you choose Paste Link?
----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================
Brian Reilly, MVP - 03 Dec 2007 17:57 GMT In addition to Steve's question, what version of Office are you using? Behavior changes over versions but the underlying ability to link is in there since at least Office 97.
Brian Reilly, MVP
>I am trying to link an excel file and a powerpoint file, so that if i >change some cells in excel (let's say a number within a cell ) , the [quoted text clipped - 9 lines] > >many thank in advance Steve Rindsberg - 04 Dec 2007 02:08 GMT > In addition to Steve's question, what version of Office are you using? > Behavior changes over versions but the underlying ability to link is > in there since at least Office 97. Just fwiw, I popped some text into a sheet, copied it and tried to paste (not link) into PPT, but used PasteSpecial to make sure I could see what it was going to give me. Various text options were all it offered, whereas I was after an Excel object.
It wouldn't let me do that until I went back into the sheet and entered a formula into one of the cells.
If they make it any easier to use, I'll have to shoot it.
----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================
Brian Reilly, MVP - 07 Dec 2007 16:41 GMT Steve, If I understand you correctly, that is not what I get here in 2003. Paste Special always gives me an XL object as a choice. Paste gives me a PPT Table. Check it with Uber Piggie. Or did I misunderstand you again?
Brian Reilly, MVP
>> In addition to Steve's question, what version of Office are you using? >> Behavior changes over versions but the underlying ability to link is [quoted text clipped - 15 lines] >PPTools: www.pptools.com >================================================ Steve Rindsberg - 07 Dec 2007 18:38 GMT > Steve, > If I understand you correctly, that is not what I get here in 2003. > Paste Special always gives me an XL object as a choice. Paste gives me > a PPT Table. Check it with Uber Piggie. Or did I misunderstand you > again? It gets weirder. Some days I have to beat it with a large stick to get it to give me Excel object as a choice for PasteSpecial, other times I can't get it NOT to include that at the top of the list.
Freakish.
> Brian Reilly, MVP > [quoted text clipped - 17 lines] > >PPTools: www.pptools.com > >================================================ ----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================
Brian Reilly, MVP - 08 Dec 2007 23:34 GMT Steve, I have never seen that happen. I always have Excel Object as top of the list for Paste Special.
Brian Reilly, MVP
>> Steve, >> If I understand you correctly, that is not what I get here in 2003. [quoted text clipped - 35 lines] >PPTools: www.pptools.com >================================================ Steve Rindsberg - 09 Dec 2007 03:16 GMT > Steve, > I have never seen that happen. I always have Excel Object as top of > the list for Paste Special. What can I tell ya? It happens sometimes, sometimes not. I sure wish I could nail down the logic.
----------------------------------------- Steve Rindsberg, PPT MVP PPT FAQ: www.pptfaq.com PPTools: www.pptools.com ================================================
|
|
|