Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Pasting an excel Chart into a specific area in Powerpoint

Hello!

So I'm having this problem. The problem is probably that I am not that
strong with VBA, but here goes:

I want to automate creation of charts and put them into a powerpoint
deck. There are 100 charts that need to be created on a monthly
basis. I am working on an engine to do this.

I am stuck trying to copy a chart from excel and paste it into a
specific place on a specific powerpoint slide.
The pasting is going OK, but what I really want to do is to paste it
into a specific spot on the slide so that I can maintain the format of
the slide if I apply a style template to the presentation.

Here is an example:
http://www.qaready.com/ppt/example.ppt

There are 2 slides. The first one is wrong because the chart I pasted
into it is floating. The second one is right because I selected the
graph shape object, then pasted the chart into it. The question is,
how do I do this from VBA (in Excel).

See below: 'HERE IS WHERE THINGS GO AWRY



Here is my code that does not work:



Sub CopyChartToPres(PPApp As PowerPoint.Application, PPPres As
PowerPoint.Presentation, PPSlide As PowerPoint.Slide, EXChart As
Chart)
' Uses Early Binding to the PowerPoint Object Model
' Set a VBE reference to Microsoft PowerPoint Object Library

' Make sure a chart is selected
If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation, _
"No Chart Selected"
Else
' Reference existing instance of PowerPoint
' Set PPApp = GetObject(, "Powerpoint.Application") commented
' Reference active presentation


' Copy chart as a picture
EXChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, _
Format:=xlPicture

' Set PPPres = PPApp.ActivePresentation
PPPres.Application.Activate

PPApp.ActiveWindow.ViewType = ppViewSlide

' Paste chart
'PPSlide.Shapes.Paste.Select

PPSlide.Select

PPSlide.Shapes.Paste


' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End If

End Sub


Thenks in advance,

Gleep

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default Pasting an excel Chart into a specific area in Powerpoint

Use these lines to control the position of objects on slides...

With PPApp.ActiveWindow.Selection.ShapeRange
.Left = 71.88
.Top = 179.88
End With

..left controls horizontal positioning
..top controls vertical positioning

The example places the object 1" from the left edge and 2.5" from the
top edge.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Pasting an excel Chart into a specific area in Powerpoint

On May 10, 6:15 pm, ward376 wrote:
Use these lines to control the position of objects on slides...

With PPApp.ActiveWindow.Selection.ShapeRange
.Left = 71.88
.Top = 179.88
End With

.left controls horizontal positioning
.top controls vertical positioning

The example places the object 1" from the left edge and 2.5" from the
top edge.



Thanks! I've tried this and it's a decent workaround, however

this isn't really what I want to do, I want it to become part of the
slide layout so that if I reformat the slide, the chart will move into
its proper spot.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Pasting an excel Chart into a specific area in Powerpoint

Put a dummy rectangle on the slide, name it something like
shpChartPlaceholder, which I think you can only do in VBA:

ActiveWindow.Selection.ShapeRange.Name = "shpChartPlaceholder"

Whenever you reformat the slide, change the position and shape of this
rectangle. When not formatting it, use VBA to hide the placeholder:

Activewindow.Selection.SlideRange.Shapes("shpChart Placeholder").Visible
= False

Then your code can reference the placeholder:

Dim shpPlaceHolder As PowerPoint.Shape
Set shpPlaceHolder =
PPApp.Activewindow.Selection.SlideRange.Shapes("sh pChartPlaceholder")
With PPApp.ActiveWindow.Selection.ShapeRange
.Left = shpPlaceHolder.Left
.Top = shpPlaceHolder.Top
.Width = shpPlaceHolder.Width
.Height = shpPlaceHolder.Height
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


wrote in message
oups.com...
On May 10, 6:15 pm, ward376 wrote:
Use these lines to control the position of objects on slides...

With PPApp.ActiveWindow.Selection.ShapeRange
.Left = 71.88
.Top = 179.88
End With

.left controls horizontal positioning
.top controls vertical positioning

The example places the object 1" from the left edge and 2.5" from the
top edge.



Thanks! I've tried this and it's a decent workaround, however

this isn't really what I want to do, I want it to become part of the
slide layout so that if I reformat the slide, the chart will move into
its proper spot.



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
Plot area distorted when I copy Excel chart into Powerpoint [email protected] Charts and Charting in Excel 1 May 17th 07 12:56 PM
Pasting from Excel to Powerpoint Jim Jackson Excel Programming 2 August 21st 06 01:33 PM
Pasting a chart to PowerPoint from Excel mark Excel Programming 2 May 1st 06 01:29 AM
Pasting Charts from Excel to PowerPoint Willow[_5_] Excel Programming 0 April 14th 06 03:23 PM
Pasting excel chart into powerpoint Cowtoon Charts and Charting in Excel 1 January 18th 06 10:19 PM


All times are GMT +1. The time now is 10:55 AM.

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"