Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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.SlideRa nge.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.SlideInde x) ' 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 "mucrick" wrote: 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.SlideRa nge.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.SlideInde x) ' 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Link Macros Excel 2007 | Excel Discussion (Misc queries) | |||
How to link an application to Macros? | Excel Discussion (Misc queries) | |||
new link for excel macros | Links and Linking in Excel | |||
Hyperlink Link Field to link to file on website | Excel Programming | |||
stopping the link of macros in one workbook with every other exce. | Excel Discussion (Misc queries) |