Solved

OLE Parent Object Reference

Posted on 2003-10-23
4
388 Views
Last Modified: 2008-02-01
I have a PowerPoint app with an embedded Excel worksheet on it. There is code behind the Excel sheet, but I need to access an ID number in a textbox on the PPt app. Is there any way for the Excel OLE object to access the parent PPt object? (ie OLEFormat object)
0
Comment
Question by:Taffarel
  • 3
4 Comments
 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 9612229
I think the PowerPoint slide can access the Excel worksheet, but not vice versa.  Thus, you would have to add code to the PowerPoint slide to convey the ID number to your worksheet.  The Object property of the OLEObject should return an Excel Sheet object.  Have the Powerpoint slide write the value into a cell on the Excel sheet, and then have your Excel code read the value from that cell.
0
 

Author Comment

by:Taffarel
ID: 9615465
The PPt app displays data about a project. There are several of these,  one for each project we have (all based off the same PPt template). The user opens the PPt app in normal view (not slideshow view, so no code fires in PPt) and updates the data in the Excel sheet. When they do this, I need to run some code to update corresponding values in an MSAccess database. However, I need the ID from the PPt app. Since no code fires in PPt in normal view and PPt also starts with no default objects set up (Me, App, etc.), I can't handle any events or run code there, unless the user actually starts the PPt slideshow and triggers a macro. So the only place I can handle any events is within Excel. Is there any way to make code run in PPt in normal view? Is there anything that fires when the app is opened (ie. AutoExec function)? I toyed with the idea of using WinAPI to get an hWnd to the PPt app window, but is there any way to use the handle to retrieve a reference to the PPt app itself?
0
 
LVL 5

Accepted Solution

by:
JMoon5FTM earned 160 total points
ID: 9745245
That sounds tough...I've never been able to figure out why Powerpoint slides don't fire events.  There's no reason something this simple should be so difficult.

I've got two ideas on the Powerpoint side:
  1.  If you can add a control to the slide that raises events in normal view, you can use that event handler.  Ideally, you should be able to make this control invisible, and it should fire its event immediately upon its initialization.  I don't know off-hand what controls might be able to do this, but I'll look into it.
  2.  If you've got a tool that can compile code, you can manufacture the aforementioned control, or perhaps a Powerpoint add-in to do the same thing.

From Excel, if you can get Powerpoint's hWnd, AccessibleObjectFromWindow will let you transform that hWnd into an object you can use.

Private Declare Function AccessibleObjectFromWindow lib "oleacc" (byval hWnd as Long, byval ID as Long, IID as UUID, obj as ...) as Long

Replace ... with the interface you expect to use.  Then, fill in a UUID structure with the IID of that interface.  ID should be OBJID_NATIVEOM.
0
 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 9745257
OBJID_NATIVEOM is &hFFFFFFF0.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now