ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Solution: How to programmaticaly leave "edit mode" (https://www.excelbanter.com/excel-programming/308812-solution-how-programmaticaly-leave-edit-mode.html)

David Owens

Solution: How to programmaticaly leave "edit mode"
 
There have been many posts looking for a way to programmatically exit
Excel's edit mode. After almost a year of periodically trying I believe the
following to work on both Excel 2000 & 2003. Your mileage may vary.

The solution is based on Excel's current behavior of committing the open
edit before closing the document. Excel will also allow the integrated code
{mine is a COM addin}to cancel a close.

In a nutshell, to close an open edit, call close on the ActiveWorkbook and
set cancel to VARIANT_TRUE in an onClose handler.

It's not pretty, but it seems less fragile than sending keys {which I for
one never got to work}.

thoughts? reactions? improvements?
cheers,
dave



Doug Glancy

Solution: How to programmaticaly leave "edit mode"
 
David,

I'm confused. How do you call the procedure while you are editing a cell?
Can you give an example of when you would run this and how it would work?

Doug

"David Owens" wrote in message
...
There have been many posts looking for a way to programmatically exit
Excel's edit mode. After almost a year of periodically trying I believe

the
following to work on both Excel 2000 & 2003. Your mileage may vary.

The solution is based on Excel's current behavior of committing the open
edit before closing the document. Excel will also allow the integrated

code
{mine is a COM addin}to cancel a close.

In a nutshell, to close an open edit, call close on the ActiveWorkbook and
set cancel to VARIANT_TRUE in an onClose handler.

It's not pretty, but it seems less fragile than sending keys {which I for
one never got to work}.

thoughts? reactions? improvements?
cheers,
dave





Tom Ogilvy

Solution: How to programmaticaly leave "edit mode"
 
He is having code manipulate Excel. The problem is that if the user is in
edit mode when the code runs, the code fails. There is no way to chekc if
the user is in edit mode, so this way, the code can force the user out of
edit mode so the code can then do its very important work.

--
Regards,
Tom Ogilvy

"Doug Glancy" wrote in message
...
David,

I'm confused. How do you call the procedure while you are editing a cell?
Can you give an example of when you would run this and how it would work?

Doug

"David Owens" wrote in message
...
There have been many posts looking for a way to programmatically exit
Excel's edit mode. After almost a year of periodically trying I believe

the
following to work on both Excel 2000 & 2003. Your mileage may vary.

The solution is based on Excel's current behavior of committing the open
edit before closing the document. Excel will also allow the integrated

code
{mine is a COM addin}to cancel a close.

In a nutshell, to close an open edit, call close on the ActiveWorkbook

and
set cancel to VARIANT_TRUE in an onClose handler.

It's not pretty, but it seems less fragile than sending keys {which I

for
one never got to work}.

thoughts? reactions? improvements?
cheers,
dave








All times are GMT +1. The time now is 12:31 AM.

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