Exit from Excel edit mode using IDispatch

G

Goofball

Exit from Excel edit mode using IDispatch

I've searched Internet and groups, but can't find a solution to this.
Can anyone, please, tell, is there any way to perform exit from Excel
edit mode in programmatic way with either accepting user input or
cancelling it. I need to do that from another application using the
IDispatch pointer to Excel. Here is another trick comes out: I can get
the pointer to the active instance of Excel. I can even determine if
is it in edit mode (just call the function to activate my ole object
of excel and I get the E_OUTOFMEMORY error. That is understandable).
So when I detect, that excel is in Edit mode, is there any way to tell
excel to exit that mode? Any ideas? Thanks for any help.
 
C

Colby Africa

It sounds like you need to call the following:

IOleInplaceObject::InPlaceDeactivate()
IOleObject::Close()
IUnknown::Realease()

In order to fully exit and close the Excel process. It has been years
since I did anything like that though!

HTH,

Colby
 
G

Goofball

Thanks, however the problem is a bit different.

User opens some file and starts editing the cell, thus putting excel
into the edit mode. Then I launch my application that works with excel
ole object. And I can't activate that object, bacause of an error.
I've ivestigated that issue and found out, that this is because excel
is in the edit mode. So, I basically need to tell excel to exit that
mode. If its possible :)
 
A

Andrei Smolin [Add-in Express]

Hello,

Excel provides the Application.Interactive property. Try (and catch) to set
it to false. If the exception fires, you cannot do anything because the edit
mode is on.

Regards from Belarus,

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com
 
A

Andrei Smolin [Add-in Express]

If this is possible, I'd rather not take upon me the responsibility for
saving changes made by
the user.

Regards from Belarus,

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com
 
S

Steve Dalton

This probably is a horrible way to approach the problem, from a style point
of view, but would sending the Excel application either an ESC (would clear
edit and other user-interaction modes) or ENTER (would accept user input or
execute a paste operation, etc.) keystroke via the Win32 API work for you?
The latter might carry risks that are unacceptable, the user getting things
copied over existing cells, for example.
 

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