ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deactivate Code (https://www.excelbanter.com/excel-programming/397471-deactivate-code.html)

Paul

Deactivate Code
 
I have a model which allows users to select a range of items to print, and it
can be used from a variety of other model sources.

When it is used it displays the list, allows them to select, then has two
buttons - one to process and one to exit.

However, if they simply activate another workbook the process becomes lost.

What I want to do is place some code in the WorkbookDeactivate event that
will ask whether this is what they want to do, then return without
deactivating the selection model if they select that option. A messagebox in
the deactivate code gives me the response, but how do I pass the user back to
the workbook they have just tried to deactivate ?

(Sorry for the long-winded explanation)

joel

Deactivate Code
 
I think you are over complicating the problem. ThisWorkbook needs to be
added to your code which will return the code to the workbook where the code
is executing rather than any other workbook. The default window is the
active window which is the newly opened workbook. Simply adding
Thisworkbook.Activate should solve the problem.

"Paul" wrote:

I have a model which allows users to select a range of items to print, and it
can be used from a variety of other model sources.

When it is used it displays the list, allows them to select, then has two
buttons - one to process and one to exit.

However, if they simply activate another workbook the process becomes lost.

What I want to do is place some code in the WorkbookDeactivate event that
will ask whether this is what they want to do, then return without
deactivating the selection model if they select that option. A messagebox in
the deactivate code gives me the response, but how do I pass the user back to
the workbook they have just tried to deactivate ?

(Sorry for the long-winded explanation)


Paul

Deactivate Code
 
As always the simplest answers are the best.

Many thanks

"Joel" wrote:

I think you are over complicating the problem. ThisWorkbook needs to be
added to your code which will return the code to the workbook where the code
is executing rather than any other workbook. The default window is the
active window which is the newly opened workbook. Simply adding
Thisworkbook.Activate should solve the problem.

"Paul" wrote:

I have a model which allows users to select a range of items to print, and it
can be used from a variety of other model sources.

When it is used it displays the list, allows them to select, then has two
buttons - one to process and one to exit.

However, if they simply activate another workbook the process becomes lost.

What I want to do is place some code in the WorkbookDeactivate event that
will ask whether this is what they want to do, then return without
deactivating the selection model if they select that option. A messagebox in
the deactivate code gives me the response, but how do I pass the user back to
the workbook they have just tried to deactivate ?

(Sorry for the long-winded explanation)



All times are GMT +1. The time now is 12:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com