user editing cell when code runs

L

lahd

Hello

I'm not sure about the terminology, but my situation is that a user is in
the middle of editing the contents of a cell and then clicks on a toolbar
button, and interacts with a custom form - causing the program to either
write the "open" cell (the cell currently being edited) or create a new sheet
in the workbook. In either case the operation throws an exception.

Is there a command that I can use to tell excel to end the user edit? That
way I can end the edit prior to running any of my custom forms and thus avoid
the problem - rather than handling exceptions everywhere.
Thanks in advance
Dave
 
L

lahd

No ideas from anyone? Really? Not even help with the language? What do you
call the state of the system when the user is in the middle of editing a cell?
 
D

Dave Peterson

I call it edit mode.

Jan Karel Pieterse posted this. I think it should work in xl2003 and below.
I'm not sure what you'd check in xl2007's ribbon.


When XL is in editing mode, certain menu items are disabled. You could check for
the enabled property of them.

E.g.:

Sub Editing()
If Application.CommandBars(1).FindControl(ID:=23, _
recursive:=True).Enabled = False Then
MsgBox "Editing"
Else
MsgBox "Not editing"
End If
End Sub


=========
Maybe you can check that status before your code does anything.
 
J

Jim Rech

How do you run that macro when you're in edit mode, Dave? Aren't macros
disabled then? The only way I recall "achieving" that was with a Windows
API callback ontime function. I think it crashed Excel<g>.

--
Jim
|I call it edit mode.
|
| Jan Karel Pieterse posted this. I think it should work in xl2003 and
below.
| I'm not sure what you'd check in xl2007's ribbon.
|
|
| When XL is in editing mode, certain menu items are disabled. You could
check for
| the enabled property of them.
|
| E.g.:
|
| Sub Editing()
| If Application.CommandBars(1).FindControl(ID:=23, _
| recursive:=True).Enabled = False Then
| MsgBox "Editing"
| Else
| MsgBox "Not editing"
| End If
| End Sub
|
|
| =========
| Maybe you can check that status before your code does anything.
|
|
|
| lahd wrote:
| >
| > No ideas from anyone? Really? Not even help with the language? What
do you
| > call the state of the system when the user is in the middle of editing a
cell?
|
| --
|
| Dave Peterson
 
L

lahd

Well, I've got a toolbar (which happens to be a VSTO add-in) and I can start
editing a cell then click on a toolbar button.

Thanks for the answer Dave
 
D

Dave Peterson

I never have.

So I'm glad lhad answered!

Jim said:
How do you run that macro when you're in edit mode, Dave? Aren't macros
disabled then? The only way I recall "achieving" that was with a Windows
API callback ontime function. I think it crashed Excel<g>.

--
Jim
|I call it edit mode.
|
| Jan Karel Pieterse posted this. I think it should work in xl2003 and
below.
| I'm not sure what you'd check in xl2007's ribbon.
|
|
| When XL is in editing mode, certain menu items are disabled. You could
check for
| the enabled property of them.
|
| E.g.:
|
| Sub Editing()
| If Application.CommandBars(1).FindControl(ID:=23, _
| recursive:=True).Enabled = False Then
| MsgBox "Editing"
| Else
| MsgBox "Not editing"
| End If
| End Sub
|
|
| =========
| Maybe you can check that status before your code does anything.
|
|
|
| lahd wrote:
| >
| > No ideas from anyone? Really? Not even help with the language? What
do you
| > call the state of the system when the user is in the middle of editing a
cell?
|
| --
|
| Dave Peterson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top