How do I detect and commit the current cell edition?

S

ssissa

Hi,

How can I detect that the user is currently editing a cell, and to commit
the edit?

I am trying to call SaveCopyAs from a COM add-in and I get a COM exception
if a cell is being edited. I would like to finish the edit to correctly save
the workbook without an exception.

Thanks,
Bret
 
J

Jim Thomlinson

The editing of a cell does not generate any events. There is a change event
but it only fires when the editing is complete...
 
P

Peter Huang [MSFT]

Hi Bret,

Based on my research through the whole Word Object Modal, there is no such
a property or event to know if now we are in edit mode.
But I think you may try to try catch and then use the code below to end the
edit mode.
In Edit Mode, the Excel messge will enter a loop(similar as a modal
dialog,msgbox), so most of menu and button will be grey out.
Based on my test, it will work in the Save Button.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
MsgBox Application.ActiveCell.AddressLocal
Debug.Print "Save"
Cells(1, 1).Select
End Sub


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi Bret,

Have you tried my suggestion?
Did that work for you?
If you still have any concern, please feel free to post here.


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

ssissa

Hi Peter,

Thanks for your help.

I didn't follow exactly how your suggestion can help me, and I haven't had a
chance yet to play further on your ideas.

I can see that Cells(1,1).Select() will probably end any editing action to
move the selection. However this is not acceptable for me, because if the
user has a normal selection, I don't want to disrupt it. I didn't follow how
you were first detecting the edit mode? Are you suggesting that I can test if
a certain menu button is disabled?

Thanks,
Bret
 
P

Peter Huang [MSFT]

Hi Bret,

I am sorry if I did not make it clear.
As Jim suggested, there is no such an event which will generate when we
are editing a cell.

Per your descritpion, you wanted to detect the edit status because if you
are trying to SaveCopyAs, you will get exception if the cell is in editing.

So my suggest is that, when we try to save a file, Workbook_BeforeSave
event will fire. Which gave us a chance to make sure the cell is not in the
edit mode, so that we the Save work will not generate exception.

If I misunderstood, please feel free to post there.



Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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