A question of where the focus is

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi everyone!

I have deployed a poor-man's Search Engine built in Excel. It helps users to locate documents, searching by action (get, purchase, add, request, etc) or by string. The returned info is a listing of all applicable forms and/or procedures. It is enabled to open any of the documents in use in our company (xls, doc or pdf) and it works really well. There is only one problem I have no clue how to address, and that is the following:

When a user requests a document and it is a worksheet (.xls or .xlt) the document opens up for whatever purpose he/she invoked it. Upon finishing, the user can close the document either by the small "x" or the large "X". If he/she clicks the small "x", then the Excel doc closes and the focus returns to the Search Engine screen. If, instead, he/she chooses the large "X", then the display warnings about saving show up for both, the invoked document and the Search Engine.

I suppose an event Before_Closing will not work, because the focus is on the invoked document when the closing is executed. Anyone?

Thanks,

Chuck
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Good morning benson...
Here is the desired sequence:
1) The user, with the Search Engine front page on screen, invokes a document. It is a pdf or a doc. Does whatever with it. Upon closing the document, the focus returns to the Search Engine screen. This is the way it's working now and everyone is happy with it

2) The invoked document is an Excel worksheet. The user does whatever with it. Upon closing, I'd like it to display the saving question only as applicable to that document, thus behaving as in the pdf/doc example above . In other words, close the worksheet and return to the Search Engine screen.

Unless someone finds a method to open the invoked document on a separate window altogether, I still do not see a possible solution tor this. If you have some ideas, benson, that would be terrific!
Thanks,
Chuck
 
Upvote 0
Hi,
hmm that is a doosie as its opening up on the same instance so will always try to save and close BOTH workbooks.

You need to open a whole new instance, try the below

Code:
[FONT=Arial]Dim xlApp as Excel.Application
set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open FileName:="C:\test.xls"[/FONT]

placing the real file name where test.xls is :) let me know how it goes
 
Upvote 0
Good morning, benson (well, morning here in Long Island...)

Your suggested idea works EXACTLY as the Doctor ordered! I wish I could buy you a Foster tonight...

Thank you immensely.

Chuck
 
Upvote 0
Good morning, benson (well, morning here in Long Island...)

Your suggested idea works EXACTLY as the Doctor ordered! I wish I could buy you a Foster tonight...

Thank you immensely.

Chuck

Hi Chuck
Always happy to help. I will take the suggested beer from my fridge and send the bill :)
Benson
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top