ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   From Early binding to Late binding (https://www.excelbanter.com/excel-programming/423948-early-binding-late-binding.html)

Henk

From Early binding to Late binding
 
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

On Error GoTo PPAppNotopen
Set PPApp = GetObject(, "Powerpoint.Application")
On Error GoTo PPPresNotopen
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewNormal
On Error GoTo 0

NewIndex = PPPres.Slides.Count + 1
PPPres.Slides.Add(Index:=NewIndex, Layout:=ppLayoutBlank).Select

Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRa nge.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

a = MsgBox("Chart has been copied to your PowerPoint presentation.",
vbOKOnly, "Chart copied to PowerPoint")

Exit Sub

PPAppNotopen:

a = MsgBox("PowerPoint is not available at the moment." & Chr(10) & "Open
PowerPoint and the presentation where the chart should be copied to first and
then try again.", vbOKOnly, "PowerPoint not active")

Exit Sub

PPPresNotopen:

a = MsgBox("There is no PowerPoint presentation available at the moment." &
Chr(10) & "Open the PowerPoint presentation where the chart should be copied
to first and then try again.", vbOKOnly, "No PowerPoint presentation
available")

Exit Sub

End Sub

================================================== ================================================== ======

Hope you can help me out.

Henk

Bob Phillips[_3_]

From Early binding to Late binding
 
See other thread.

--
__________________________________
HTH

Bob

"Henk" wrote in message
...
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

On Error GoTo PPAppNotopen
Set PPApp = GetObject(, "Powerpoint.Application")
On Error GoTo PPPresNotopen
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewNormal
On Error GoTo 0

NewIndex = PPPres.Slides.Count + 1
PPPres.Slides.Add(Index:=NewIndex, Layout:=ppLayoutBlank).Select

Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRa nge.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

a = MsgBox("Chart has been copied to your PowerPoint presentation.",
vbOKOnly, "Chart copied to PowerPoint")

Exit Sub

PPAppNotopen:

a = MsgBox("PowerPoint is not available at the moment." & Chr(10) & "Open
PowerPoint and the presentation where the chart should be copied to first
and
then try again.", vbOKOnly, "PowerPoint not active")

Exit Sub

PPPresNotopen:

a = MsgBox("There is no PowerPoint presentation available at the moment."
&
Chr(10) & "Open the PowerPoint presentation where the chart should be
copied
to first and then try again.", vbOKOnly, "No PowerPoint presentation
available")

Exit Sub

End Sub

================================================== ================================================== ======

Hope you can help me out.

Henk





All times are GMT +1. The time now is 11:29 PM.

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