Solved

OLE Parent Object Reference

Posted on 2003-10-23
4
387 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
OBJID_NATIVEOM is &hFFFFFFF0.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
z = x + y – 1 6 55
Best way to parse out a json string in VB6? 10 70
message box in access 4 33
MS Date Picker 64 bit 32 bit issue 12 42
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

772 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

14 Experts available now in Live!

Get 1:1 Help Now