Pasting from Excel to Powerpoint using VBA

Angribob

New Member
Joined
Jun 16, 2011
Messages
8
Hi Guys,

I'm new here but i hope theres some VBA experts out there who can help me with this question.

Basically I am writing a code to automate various tasks in Excel and Powerpoint. The following sub pastes the selcted item into powerpoint.

what I cant figure out is how to paste the item into the second or subsequent page of the powerpoint deck. It always just pastes it into the fist slide?!?

Alternatively a code that moves the item from page 1 to page 2 would be really usefull.

Thanks to anyone who can help

bob




Public Function Paste()

'Sets up to use Powerpoint

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

' Reference existing instance of PowerPoint
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)


' Paste chart
PPSlide.Shapes.Paste.Select

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

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Ok I have another problem!

I need to actually activate the slide not simply paste there.

This will allow me to select the item after pasting it

(PPSlides.shapes.Paste.Select)

and thus be able to move it to the correct position.

Do you know how to do this?


The error message I am recieving reads

Run-time error '-2147188160 (80048240)':

ShapeRange (unknown member): Invalid request. To select a shape its view must be active


Thanks again!

Bob
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,814
Members
452,945
Latest member
Bib195

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top