From Early to Late bind

H

Henk

I want to convert the following code from Early binding to Late binding.
Anyone any idea how to do that?

Public Sub ChartToPowerPoint()
Application.ScreenUpdating = False
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim NewIndex As Integer
Dim ChartName As String
ChartName = ActiveSheet.Name
ActiveSheet.ChartObjects(ChartName).Activate
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewNormal
NewIndex = PPPres.Slides.Count + 1
PPPres.Slides.Add(Index:=NewIndex, Layout:=ppLayoutBlank).Select
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideNumber)
PPApp.ActiveWindow.ViewType = ppViewSlide
PPSlide.Shapes.Paste.Select
PPApp.ActiveWindow.Selection.ShapeRange.Height = 303.5
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
PPApp.ActiveWindow.ViewType = ppViewNormal
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub

Hope you can help me out.

Henk
 
B

Bob Phillips

Untested

Public Sub ChartToPowerPoint()
Const ppLayoutBlank As Long = 12
Const ppViewNormal As Long = 9
Const ppViewSlide As Long = 1
Application.ScreenUpdating = False
Dim PPApp As Object
Dim PPPres As Object
Dim PPSlide As Object
Dim NewIndex As Long
Dim ChartName As String
ChartName = ActiveSheet.Name
ActiveSheet.ChartObjects(ChartName).Activate
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewNormal
NewIndex = PPPres.Slides.Count + 1
PPPres.Slides.Add(Index:=NewIndex, Layout:=ppLayoutBlank).Select
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideNumber)
PPApp.ActiveWindow.ViewType = ppViewSlide
PPSlide.Shapes.Paste.Select
PPApp.ActiveWindow.Selection.ShapeRange.Height = 303.5
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
PPApp.ActiveWindow.ViewType = ppViewNormal
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
 
H

Henk

tHenks Bob. Consider it tested. Works perfectly (at this moment).

Apologies for sending my question several times, but I got an error message
each time seniding it. Seems that a lot of other people have the same problem.
 
B

Bob Phillips

Perfectly understood Henk, it is the forum software not you,. We are seeing
hundreds of duplicates in the NNTP newsgroups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top