Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Powerpoint charting from excel
Hi,
I have put my code below that I am attempting to open PowerPoint and insert a new slide containing a chart - however when I try to access the chart (lines highlighted with a *** below) the program crashes - is there anyone who can help me with the correct code please? Many thanks in advance KJD Dim oPPTShape As PowerPoint.Shape Dim rngNewRange As Excel.Range Dim oGraph As Object Dim lLastSlide As Long ' Change this to the auto layout you want to use. This value can be ' any PpSlideLayout constant. Const DEFAULT_AUTO_LAYOUT As Long = ppLayoutChart ' Get the number of slides in the active presentation. lLastSlide = oPPTApp.ActivePresentation.Slides.Count lLastSlide = lLastSlide + 1 oPPTApp.ActivePresentation.Slides.Add lLastSlide, DEFAULT_AUTO_LAYOUT With oPPTApp.ActivePresentation.Slides(lLastSlide) With .Shapes(1) With .TextFrame.TextRange .Text = chart_title .Font.Name = "Arial" .Font.Size = 24 End With End With Set oPPTShape = oPPTApp.ActivePresentation.Slides (lLastSlide).Shapes(2) **** oPPTShape.OLEFormat.Activate **** Set rngNewRange = Sheets("charts").Range (chart_range) **** Sheets("charts").Select **** Range(chart_range).Select **** rngNewRange.Copy **** Set oGraph = .OLEFormat.Object **** oGraph.Application.DataSheet.Range ("A0:Z100").Delete **** oGraph.Application.DataSheet.Range ("A0").Paste False **** oGraph.Application.Update Set oPPTShape = Nothing End With |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Powerpoint charting from excel
You have Excel, why not create a real chart in Excel, and paste it into
PowerPoint? http://peltiertech.com/Excel/XL_PPT.html If you insist on using it, the PowerPoint FAQ page has some hints for automating MS Graph: http://www.rdpslides.com/pptfaq/FAQ00496.htm Also Shyam Pillai has a bit about VBA and MSG: http://www.mvps.org/skp/vba.htm And you could always try the Microsoft Knowledge Base. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ KJD wrote: Hi, I have put my code below that I am attempting to open PowerPoint and insert a new slide containing a chart - however when I try to access the chart (lines highlighted with a *** below) the program crashes - is there anyone who can help me with the correct code please? Many thanks in advance KJD Dim oPPTShape As PowerPoint.Shape Dim rngNewRange As Excel.Range Dim oGraph As Object Dim lLastSlide As Long ' Change this to the auto layout you want to use. This value can be ' any PpSlideLayout constant. Const DEFAULT_AUTO_LAYOUT As Long = ppLayoutChart ' Get the number of slides in the active presentation. lLastSlide = oPPTApp.ActivePresentation.Slides.Count lLastSlide = lLastSlide + 1 oPPTApp.ActivePresentation.Slides.Add lLastSlide, DEFAULT_AUTO_LAYOUT With oPPTApp.ActivePresentation.Slides(lLastSlide) With .Shapes(1) With .TextFrame.TextRange .Text = chart_title .Font.Name = "Arial" .Font.Size = 24 End With End With Set oPPTShape = oPPTApp.ActivePresentation.Slides (lLastSlide).Shapes(2) **** oPPTShape.OLEFormat.Activate **** Set rngNewRange = Sheets("charts").Range (chart_range) **** Sheets("charts").Select **** Range(chart_range).Select **** rngNewRange.Copy **** Set oGraph = .OLEFormat.Object **** oGraph.Application.DataSheet.Range ("A0:Z100").Delete **** oGraph.Application.DataSheet.Range ("A0").Paste False **** oGraph.Application.Update Set oPPTShape = Nothing End With |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel-Powerpoint | Charts and Charting in Excel | |||
charting from excel to PowerPoint | Charts and Charting in Excel | |||
excel to powerpoint | Excel Worksheet Functions | |||
EXCEL AND POWERPOINT | New Users to Excel | |||
Custom charting - Stacked charting with a line | Charts and Charting in Excel |