The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Opening another app in a vb6 window

We access MS Excel from our app a lot.  OLE experimentation went horribly, so we create an Excel instance and go from there.

The problem is keeping our app and Excel in synch (from the user's pov).  When we bring up Excel, our app's window shrinks and Excel covers the rest of the screen.  Decent, but when the user moves to a third app, it is easy to forget that the two apps are related.  And the user gets lost.

At a minimum, I'd love to capture an event from excel telling the app to land on top other windows.  But what I really want is to invoke Excel within a window in the app.  The entire thing - toolbar, icon, everything.

Is this possible?

Bankstrong Send private email
Tuesday, October 11, 2005
I'd probably rethink your design, or try OLE (again)
Arafangion Send private email
Tuesday, October 11, 2005
It's possible, but it's not much fun.  Somewhere on MSDN there's a bunch of sample code and the extra widgetry that you'll need, but it's given me so many headaches I gave up and went back to OLE...
Mat Hall Send private email
Wednesday, October 12, 2005
You could try using the Windows API for managing windows.

1) User click on your UI and brings up Excel
2) Your app doesn't minimize but hides with a background loop looking at the status of the Excel Window
3) The user exits Excel and the background loop show your app again.

This assume the your app works by not using alt-tab to switch between the two. If you do rely on alt-tab this I would have your background only hide the app if the focus is NOT on your app and not on the Excel App.

Again all of this can be done thourgh Windows API functions
Rob Conley Send private email
Wednesday, October 12, 2005
Is this a thick client app ?

You could trap the open / exit / lose focus etc windows messages being sent by Excel on those events.


Why not reference MS Office object from your VB project and put a spreadsheet onto a modal form ? This retains all the functionality of using Excel, with the added advantage that you can control how its displayed.

User can still access 3rd app (now 2nd), including excel, but switching back to your app takes them straight to the open spreadsheet (resized to fill the modal form).

[or am I missing the point]
Justin Send private email
Wednesday, October 12, 2005
Hi Bankstrong,

I think we've had this dance before (some months ago).

We talked about options such as a middle-man Excel add-in (COM or XLA) to trigger events at an applications level, using the windows API to iterate through active windows, using Office Web Components (grid) to simulate an Excel worksheet in your app. I imagine that none of these paths proved fruitful.

Could you provide some more context regarding the objectives between your app and Excel (what are you trying to achieve and in what context) and what the constraints are?

Marcus from Melbourne
Saturday, October 15, 2005
Marcus -

It could be the aluminum in my deodorant, but I don't remember the previous conversation. 

The app (let's call it "SR") does a number of tasks through excel.  It text imports via excel because this allows:
a) use of Excel's massive formula library in a format that is familiar to our users
b) pleasant formatting of data for user review
c) excellent error reporting (colors, good error messages, searching through 200,000 records for specific problems, etc.)

We also output reports via Excel because:
1) User familiarity with Excel allows them to easily create new types of reports if desired
2) OLAP capability in PivotCharts lets the user work with large data sets and see what's going on

The problem (as I vaguely remember it) with OLE is that it does not have a normal Excel interface and is missing a few commands.  We don't want to hide the Excelness of Excel - we just want to tie it in more closely.  So, for example, we add our logo to the charts.

We have pretty effective over Excel, but there are still a few flaws:

- We can't tie the two apps closely enough.  This could be solved if we could get an event from Excel telling SR that Excel has just been selected (and that SR needs to move to the top window behind Excel).  It could also work if we could present Excel (or any app) within an SR window.
- We don't know how to read the state of "user is entering data".  If the user is typing into a cell, anything we do errors out.

Bankstrong Send private email
Saturday, October 15, 2005
Hi Bankstrong,

Our prior communiqué was also on this forum (not verbal). This might trigger something that the aluminium has corroded.

I've developed apps with embedded Excel worksheets before but never tried to encompass the full Excel GUI - toolbars and all.

I'll have a stew over it for a day or so and see if I get any inspirations.

Marcus from Melbourne
Sunday, October 16, 2005

Have you considered watching the Excel window to see if it's selected/active, etc.?  You can do that very easily with AutoIt Script. You can do things like "is Excel selected" or "wait for the XYZ window to become active", "close XYZ window", "click OK in the XYZ Windows". Quite powerful for "gluing" GUI's together.

Autoit  is a scripting language for controlling windows Apps.  It can do this sort of thing very easily. (We use it to interact with Windows programs. E.g., "Wait for XYZ Window to appear, select it, wait for it to be active, select Textbox2, type "hell world").

AutoIT also,  has a DLL/COM library that you can call all of these functions from.

Oh, and AutoIt is freeware. Not sure of the exact licensing for including thier DLL with your program.

Mr. Analogy {Shrinkwrap µISV} Send private email
Monday, October 17, 2005
Marcus -

I think that put it together for me.

Mr. Analogy -

Awesome, confirms what I should be able to do.

Thanks both,
Bankstrong Send private email
Tuesday, October 18, 2005
Marcus, Mr. Analogy -

Thanks for the help.  We are now checking the API to see what's on top.  And the software is much better as a result.

Bankstrong Send private email
Thursday, October 27, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz