ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to cancel the Edit status (https://www.excelbanter.com/excel-programming/371401-how-cancel-edit-status.html)

Kuoming

How to cancel the Edit status
 
I use VC6 to write test data into excel file. The _Application, Workbooks,
_Workbook,Sheets and _Worksheet are initialized when program start, and test
result can be writen correctly.
But when user double click one Cell on active sheet, this Cell will be in
edit stauts, the GetRange function will cause program crash.

Range myrange;
myrange = workSheet.GetRange(COleVariant(strLine),COleVarian t(strLine));

I try to use the SendKeys function to send "ESC", still couldn't change
foucs.
Kindly help how can I cancel the Edit status or How to disable the Edit
funtion.



Tom Ogilvy

How to cancel the Edit status
 
I have never tried it, but before doing anything else,

Try Setting Application.Interactive to False


Make sure you turn it back on.

--
Regards,
Tom Ogilvy

"Kuoming" wrote in message
...
I use VC6 to write test data into excel file. The _Application, Workbooks,
_Workbook,Sheets and _Worksheet are initialized when program start, and
test
result can be writen correctly.
But when user double click one Cell on active sheet, this Cell will be in
edit stauts, the GetRange function will cause program crash.

Range myrange;
myrange = workSheet.GetRange(COleVariant(strLine),COleVarian t(strLine));

I try to use the SendKeys function to send "ESC", still couldn't change
foucs.
Kindly help how can I cancel the Edit status or How to disable the Edit
funtion.





[email protected]

How to cancel the Edit status
 
Hi both,
Just try to guess ...
How about use :
on error goto blabla
or
on error resume next

I think that will ignore the error or skip the error but never
done the procedure well.

rgds,

Halim


Tom Ogilvy menuliskan:
I have never tried it, but before doing anything else,

Try Setting Application.Interactive to False


Make sure you turn it back on.

--
Regards,
Tom Ogilvy

"Kuoming" wrote in message
...
I use VC6 to write test data into excel file. The _Application, Workbooks,
_Workbook,Sheets and _Worksheet are initialized when program start, and
test
result can be writen correctly.
But when user double click one Cell on active sheet, this Cell will be in
edit stauts, the GetRange function will cause program crash.

Range myrange;
myrange = workSheet.GetRange(COleVariant(strLine),COleVarian t(strLine));

I try to use the SendKeys function to send "ESC", still couldn't change
foucs.
Kindly help how can I cancel the Edit status or How to disable the Edit
funtion.




NickHK

How to cancel the Edit status
 
Others making add-in with .Net/Interop /C++ have this problem, because code
is trying to run whilst Excel is in edit mode.
At best, this means values are meaningless or worst (as you have found out)
a crash.

You should not be forcing users out of edit mode. If I am writing a long and
complex formula, then you cancel it all because your code wants to run, you
will not have many users.
You need you code to run at the correct time and not allow users to enter
edit mode until Excel/system is ready.

Here's one way to detect if excel is in edit mode
http://groups.google.co.uk/group/mic...7a5175d41417d3

NickHK

"Kuoming" wrote in message
...
I use VC6 to write test data into excel file. The _Application, Workbooks,
_Workbook,Sheets and _Worksheet are initialized when program start, and

test
result can be writen correctly.
But when user double click one Cell on active sheet, this Cell will be in
edit stauts, the GetRange function will cause program crash.

Range myrange;
myrange = workSheet.GetRange(COleVariant(strLine),COleVarian t(strLine));

I try to use the SendKeys function to send "ESC", still couldn't change
foucs.
Kindly help how can I cancel the Edit status or How to disable the Edit
funtion.





Kuoming

How to cancel the Edit status
 
Thanks for great help!
Is there a way to force out of edit mode?
because user not really want to input data, only error operation let it into
edit mode.
If I set the Interactive to false, user couldn't read the data.


"NickHK" wrote:

Others making add-in with .Net/Interop /C++ have this problem, because code
is trying to run whilst Excel is in edit mode.
At best, this means values are meaningless or worst (as you have found out)
a crash.

You should not be forcing users out of edit mode. If I am writing a long and
complex formula, then you cancel it all because your code wants to run, you
will not have many users.
You need you code to run at the correct time and not allow users to enter
edit mode until Excel/system is ready.

Here's one way to detect if excel is in edit mode
http://groups.google.co.uk/group/mic...7a5175d41417d3

NickHK

"Kuoming" wrote in message
...
I use VC6 to write test data into excel file. The _Application, Workbooks,
_Workbook,Sheets and _Worksheet are initialized when program start, and

test
result can be writen correctly.
But when user double click one Cell on active sheet, this Cell will be in
edit stauts, the GetRange function will cause program crash.

Range myrange;
myrange = workSheet.GetRange(COleVariant(strLine),COleVarian t(strLine));

I try to use the SendKeys function to send "ESC", still couldn't change
foucs.
Kindly help how can I cancel the Edit status or How to disable the Edit
funtion.






NickHK

How to cancel the Edit status
 
How do you know that the "user not really want to input data" ?
If are including some mind-reading ability to Excel, that may be an option,
otherwise don't do it.
If edit mode is a result of your bad code, then fix the code.

But with all this you may be better off in a NG that deals with this; those
for .Net/Interop and/or microsoft.public.excel.sdk

NickHK

"Kuoming" wrote in message
...
Thanks for great help!
Is there a way to force out of edit mode?
because user not really want to input data, only error operation let it

into
edit mode.
If I set the Interactive to false, user couldn't read the data.


"NickHK" wrote:

Others making add-in with .Net/Interop /C++ have this problem, because

code
is trying to run whilst Excel is in edit mode.
At best, this means values are meaningless or worst (as you have found

out)
a crash.

You should not be forcing users out of edit mode. If I am writing a long

and
complex formula, then you cancel it all because your code wants to run,

you
will not have many users.
You need you code to run at the correct time and not allow users to

enter
edit mode until Excel/system is ready.

Here's one way to detect if excel is in edit mode

http://groups.google.co.uk/group/mic...7a5175d41417d3

NickHK

"Kuoming" wrote in message
...
I use VC6 to write test data into excel file. The _Application,

Workbooks,
_Workbook,Sheets and _Worksheet are initialized when program start,

and
test
result can be writen correctly.
But when user double click one Cell on active sheet, this Cell will be

in
edit stauts, the GetRange function will cause program crash.

Range myrange;
myrange =

workSheet.GetRange(COleVariant(strLine),COleVarian t(strLine));

I try to use the SendKeys function to send "ESC", still couldn't

change
foucs.
Kindly help how can I cancel the Edit status or How to disable the

Edit
funtion.









All times are GMT +1. The time now is 10:08 PM.

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