Office 2003 macro won't run in Office 2007

  • Thread starter Thread starter Nickis
  • Start date Start date
N

Nickis

I did post this on the Excel Programming site, but not really a lot of
insight came back, so I'm hoping a Powerpoint expert can help!

I created a macro in Office 2003 using early binding to copy data from Excel
into Powerpoint...not the greatest code...but it worked! Now my users are
switching to Office 2007 and the code won't run! I have include what I
believe to be the relevant string of code below.

Dim objPPT As Object
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True

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

Set PPApp = GetObject(, "Powerpoint.Application")
PPApp.ActivePresentation.Slides.range(Array(13)).Select

' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
' Reference active slide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

'EXCEL CODE
Sheets("TablesforPP").Select
range("a2").Select
Selection.Copy

'POWERPOINT CODE
PPSlide.Shapes.Paste.Select

This is where it errors with the following message:

"Run-time error '-2147188160(80048240)':
Shapes (unknown member): Invalid request. Clipboard is empty or contains
data which may not be pasted here"

The data is captured by the Excel and is in the clipboard ready to paste,
and I can manually paste. By looking at how the data appears when I manually
paste I think maybe I need to "paste special" as RTF, but I'm not sure of the
coding for that. I'm not a developer, and had enough trouble getting this
all set up in 2003, now having to "convert" to 2007 is extremely frustrating!

I don't need this coding to be compatible with both Office 2003 and 2007, I
just need it to work in Office 2007. I'm sure I will run into more issues as
I cycle through the code, but if I can understand why this is happening and
fix it, I think I'll be a long way to understanding any subsequent issues.

Thanks,
Nicki
 
Does this work?

Sub myPaste()
'Early Bound
'Assumes Presentation is Open and reference set to PowerPoint
Dim PPApp As PowerPoint.Application

Set PPApp = GetObject(Class:="Powerpoint.Application")

PPApp.ActiveWindow.ViewType = ppViewSlide
PPApp.ActivePresentation.slides(13).Select
'EXCEL CODE
Sheets("Tables").Select
Range("a2").Select
Selection.Copy

'POWERPOINT CODE
PPApp.ActiveWindow.View.PasteSpecial (ppPasteRTF)
End Sub
 
It took me a while to get back to this as I was so disheartened. I checked
and I do already have SP2.

John,
Thanks so much, this does work! The placing of this item I'm pasting with
the macro and other items I'm pasting later in the code are all off, but
that's a small thing to fix. I really appreciate your help!

Nicki
 
Back
Top