Range Link and Chart Link Macros

M

mucrick

I recently upgraded to Office 2007 (from Office 2002). I used on a regular
basis macros that allowed me to link either a range or a chart to PowerPoint.
but with this upgrade, neither work. I'd GREATLY appreciate someone's
assistance in explainign what changes are required to the macros below to
allow them to be used in Office 2007.

Many thanks!

mucrick


Sub RangeToPPTLink()
' Set a VBE reference to Microsoft PowerPoint 10.0 Object Library for Office
2002,

Dim PPApp As PowerPoint.Application

Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

' Make sure a range is selected
If Not TypeName(Selection) = "Range" Then
MsgBox "Please select a worksheet range and try again.", vbExclamation, _
"No Range Selected"
Else
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

' Copy the range as a picture
Selection.Copy

' Paste the range
PPSlide.Shapes.PasteSpecial(Link:=True).Select

' Align the pasted range
' PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
' PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

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

End Sub


Sub ChartToPPTLink()
' Set a VBE reference to Microsoft PowerPoint 10.0 Object Library for Office
2002,

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

' Make sure a chart is selected
If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation, _
"No Chart Selected"
Else
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide = PPPres.Slides _
(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

' Copy chart as a picture
ActiveChart.ChartArea.Copy

' Paste chart link
PPSlide.Shapes.PasteSpecial(Link:=True).Select

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

End Sub
 
M

mucrick

I should note that the error received is on the following line:

PPSlide.Shapes.PasteSpecial(Link:=True).Select


And the error is as follows:

Runtim error: method 'pastespecial' of object 'shapes' failed
 

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