Solved

OLE Parent Object Reference

Posted on 2003-10-23
4
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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