call word Editor Redo() method in Outlook always fail

Add-in Express™ Support Service
That's what is more important than anything else

call word Editor Redo() method in Outlook always fail
 
keni zhou




Posts: 13
Joined: 2018-08-22
Dear Sir,

I would like to add some logic after user clicking redo button(ctrl+Y) in Outlook, so I intercept redo calling and shortcut "Ctrl+Y" and then call the word Redo() method as following:

WordApplication.ActiveDocument.Redo();//cannot take affect

//some other handling here

But it always return false, if just click the built-in redo button it works fine.

do you know if is there anything is wrong?


BTW, WordApplication.ActiveDocument.Undo(); works fine.


Thank you very much!
Posted 19 Oct, 2018 09:54:13 Top
Andrei Smolin


Add-in Express team


Posts: 16223
Joined: 2006-05-11
Hello Keni,

I've created an email, edited the body, undid the edits and started this VBA macro:

Sub fgsdfsdfgs()
Dim OutlookApp As Outlook.Application
Set OutlookApp = Application
Dim doc As Word.Document
Set doc = OutlookApp.ActiveInspector.WordEditor
doc.Redo
End Sub



This works fine for me.

In what event do you invoke your code?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Oct, 2018 04:44:10 Top
keni zhou




Posts: 13
Joined: 2018-08-22
Dear Andrei,

I have added a keyboard hook to intercept shortcuts,I capture this event when user press "Ctrl+X". after I calling Redo(), I cancel the the keyboard message chain(return 1).
Posted 23 Oct, 2018 22:29:42 Top
Andrei Smolin


Add-in Express team


Posts: 16223
Joined: 2006-05-11
Hello Keni,

I'd do this in the different order: if you are going to call Redo, cancel the shortcut and send PostMessage to a hidden window (or use a System.windows.Forms.Timer); when the message is received, call Redo.

The exact machinery above is implemented by the ADXKeyboardShortcut component: it raises the Action event when the message is received. The reason for using this machinery is the object model: it doesn't expect incoming calls in the KeyDown event.

HTH

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Oct, 2018 03:23:51 Top
keni zhou




Posts: 13
Joined: 2018-08-22
Thank you very much!

if so, if I can use key-up event instead of Key-down event?
Posted 25 Oct, 2018 22:09:40 Top
Andrei Smolin


Add-in Express team


Posts: 16223
Joined: 2006-05-11
keni zhou writes:
if so, if I can use key-up event instead of Key-down event?


I don't know. We've never tried doing this.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 26 Oct, 2018 04:47:57 Top