ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using excel vba to produce a powerpoint slide (https://www.excelbanter.com/excel-programming/298161-using-excel-vba-produce-powerpoint-slide.html)

KDUT

Using excel vba to produce a powerpoint slide
 
Hi,

I am writing a vba program to open powerpoint and produce
a new slide based on a column chart with data labels - I
have amanged to open powerpoint and insert a new slide of
the right type, however I cannot access the chart on the
page to change the chart options etc as well as getting to
the data sheet behind it. Has anyone got any ideas?

Please see the code that I have at the moment below

Many thanks

KDUT



' 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


Dim oPPTShape As PowerPoint.Shape
Dim rngNewRange As Excel.Range
Dim oGraph As Object

With oPPTApp.ActivePresentation.Slides(lLastSlide)
With .Shapes(1)
With .TextFrame.TextRange
.Text = chart_title
.Font.Name = "Arial"
.Font.Size = 24
End With
End With
.........




Mike Waldron[_2_]

Using excel vba to produce a powerpoint slide
 
Hi,

Yes, PowerPoint uses an application called MS Graph for
graphing. You will need to set a separate referrence to
MicroSoft Graph 9.0 library, or the highest version you
have. (from the IDE choose Tools, References). That will
give you access to the object model for MS Graph. You
need one set for Graph and one for PowerPoint. PowerPoint
alone isn't enough.

Query MS Graph on the MicroSoft web site. There are
several informative articles with code samples that will
help.

Mike
-----Original Message-----
Hi,

I am writing a vba program to open powerpoint and produce
a new slide based on a column chart with data labels - I
have amanged to open powerpoint and insert a new slide of
the right type, however I cannot access the chart on the
page to change the chart options etc as well as getting

to
the data sheet behind it. Has anyone got any ideas?

Please see the code that I have at the moment below

Many thanks

KDUT



' 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


Dim oPPTShape As PowerPoint.Shape
Dim rngNewRange As Excel.Range
Dim oGraph As Object

With oPPTApp.ActivePresentation.Slides(lLastSlide)
With .Shapes(1)
With .TextFrame.TextRange
.Text = chart_title
.Font.Name = "Arial"
.Font.Size = 24
End With
End With
.........



.



All times are GMT +1. The time now is 02:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com