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
Solved

OLE Parent Object Reference

Posted on 2003-10-23
4
390 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

807 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