S
SteveG
I am following on from an older post
http://groups.google.com/group/microsoft.public.excel.charting/msg/a96af87f70b6657f?
I have used Jon Peltier's page http://peltiertech.com/Excel/XL_PPT.html#chartppt
to try and create a macro that will open a new PPT, copy all th
echartsheets and paste as bitmap (to stop people falsifying charts!)
one to a ppt slide.
My problems are:
1) The macro only seems to work if PPT is already running (despite
using Jon's code for creating a New PPT object)
2) The bitmap solution is ok when on screen but I get people asking if
their eyes are playing tricks when we look at the printed copy. Yes
it is a bit fuzzy! What controls the resolution of a bitmap? Is it
the screen resolution?
Is there any way to prevent ungrouping of a picture?
3) Can I define the PPT template (.pot) that should be used?
4) What decides the dimensions (points, inches, cm) used for
positioning? - Are they set by the Windows regional settings?
The code is below (you can see where I have added sections - extra
indent)
I am so close to my goal but am stuck with these last few points!
Can anyone help?
Steve
Sub ChartstoPresentation()
' Set a VBE reference to Microsoft PowerPoint Object Library
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PresentationFileName As Variant
Dim SlideCount As Long
Dim iCht As Integer
' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")
' Create a presentation
Set PPPres = PPApp.Presentations.Add
' Some PowerPoint actions work best in normal slide
view
PPApp.ActiveWindow.ViewType = ppViewSlide
' Add first slide to presentation
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
' Reference existing instance of PowerPoint
'Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
'Set PPPres = PPApp.ActivePresentation
' Some PowerPoint actions work best in normal slide view
'PPApp.ActiveWindow.ViewType = ppViewSlide
For iCht = 1 To ActiveWorkbook.Charts.Count
' Copy chartsheet as a picture
ActiveWorkbook.Charts(iCht).CopyPicture _
Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
'For iCht = 1 To ActiveSheet.ChartObjects.Count
' Copy chart as a picture
' ActiveSheet.ChartObjects(iCht).Chart.CopyPicture _
' Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' position the chart
With PPApp.ActiveWindow.Selection.ShapeRange
.Top = 94 ' points
.Left = 58 ' points
.Width = 8.2 * 72
.Height = 5.6 * 72
End With
End With
Next
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
http://groups.google.com/group/microsoft.public.excel.charting/msg/a96af87f70b6657f?
I have used Jon Peltier's page http://peltiertech.com/Excel/XL_PPT.html#chartppt
to try and create a macro that will open a new PPT, copy all th
echartsheets and paste as bitmap (to stop people falsifying charts!)
one to a ppt slide.
My problems are:
1) The macro only seems to work if PPT is already running (despite
using Jon's code for creating a New PPT object)
2) The bitmap solution is ok when on screen but I get people asking if
their eyes are playing tricks when we look at the printed copy. Yes
it is a bit fuzzy! What controls the resolution of a bitmap? Is it
the screen resolution?
Is there any way to prevent ungrouping of a picture?
3) Can I define the PPT template (.pot) that should be used?
4) What decides the dimensions (points, inches, cm) used for
positioning? - Are they set by the Windows regional settings?
The code is below (you can see where I have added sections - extra
indent)
I am so close to my goal but am stuck with these last few points!
Can anyone help?
Steve
Sub ChartstoPresentation()
' Set a VBE reference to Microsoft PowerPoint Object Library
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PresentationFileName As Variant
Dim SlideCount As Long
Dim iCht As Integer
' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")
' Create a presentation
Set PPPres = PPApp.Presentations.Add
' Some PowerPoint actions work best in normal slide
view
PPApp.ActiveWindow.ViewType = ppViewSlide
' Add first slide to presentation
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
' Reference existing instance of PowerPoint
'Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
'Set PPPres = PPApp.ActivePresentation
' Some PowerPoint actions work best in normal slide view
'PPApp.ActiveWindow.ViewType = ppViewSlide
For iCht = 1 To ActiveWorkbook.Charts.Count
' Copy chartsheet as a picture
ActiveWorkbook.Charts(iCht).CopyPicture _
Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
'For iCht = 1 To ActiveSheet.ChartObjects.Count
' Copy chart as a picture
' ActiveSheet.ChartObjects(iCht).Chart.CopyPicture _
' Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' position the chart
With PPApp.ActiveWindow.Selection.ShapeRange
.Top = 94 ' points
.Left = 58 ' points
.Width = 8.2 * 72
.Height = 5.6 * 72
End With
End With
Next
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub