Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KJD KJD is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel-Powerpoint Denver Charts and Charting in Excel 1 June 21st 09 10:57 AM
charting from excel to PowerPoint HuaXC Charts and Charting in Excel 1 September 15th 06 08:27 PM
excel to powerpoint confused Excel Worksheet Functions 1 October 5th 05 05:40 PM
EXCEL AND POWERPOINT CANDELYN. CARPENTER New Users to Excel 2 May 12th 05 01:10 PM
Custom charting - Stacked charting with a line Randy Lefferts Charts and Charting in Excel 3 March 3rd 05 03:10 AM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"