Code from Powerpoint VBE not Working in Excel VBE?

A

Aaron

With a worksheet object selected in Powerpoint this code works perfectly from
PP VBE but from Excel VBE I get "Run-time error 429: ActiveX comonent can't
create object"

PowerPoint.Application.ActiveWindow.Selection.ShapeRange.Name = "testname"

Through tools references I have selected:
VBA
MS XL 11.0 obj lib
OLE auto
MS off 11.0 obj lib
MS PP 11.0 obj lib
and just for kicks I tried some MS ActiveX object libraies, but they did not
seem to help so I have deselected them now. Any ideas?
 
J

Jon Peltier

You need to declare a variable to represent the PowerPoint application:

Dim ppApp As PowerPoint.Application

Then you need to instantiate it in one of several ways. Assuming you have
Ppt running already:

Set ppApp = GetObject(, "PowerPoint.Application")

now adjust the line you posted:

ppApp.ActiveWindow.Selection.ShapeRange.Name = "testname"

Here's more on controlling one program from another:

http://peltiertech.com/Excel/XL_PPT.html

- Jon
 

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