?
Solved

OLE Parent Object Reference

Posted on 2003-10-23
4
Medium Priority
?
398 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 640 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

Technology Partners: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

770 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