Undo/Redo buttons hooking

K

Klaus Linke

Alex said:
Maybe the resident Microsoft representatives will be able to offer a solution?

There aren't many Microsoft employees hanging around in the Word newsgroups. If they do, it's usually not as representatives.

You can post a suggestion for Microsoft to the newsgroups, and Microsoft has promised to read those and to reply to a few that get a lot of feedback. You have to use the web interface for that, though:
http://www.microsoft.com/communities/newsgroups/default.mspx

What do you plan to do with your macros that intercept Undo/Redo? Maybe there's another way to achieve the same result?

Regards,
Klaus
 
A

Alex

Klaus said:
There aren't many Microsoft employees hanging around in the Word
newsgroups. If they do, it's usually not as representatives.

That's why I crossposted to microsoft.public.office.developer.com.add_ins.
I have had good experience with Wei-Dong XU and Peter Huang from MSFT
answering these questions.
You can post a suggestion for Microsoft to the newsgroups, and
Microsoft has promised to read those and to reply to a few that
get a lot of feedback. You have to use the web interface for that, though:
http://www.microsoft.com/communities/newsgroups/default.mspx

As I am an MSDN subscriber and using a valideted account to post,
MSFT guarantees a reply within 48 hours (I think).
Now if I get a satisfactory reply from you, Cindy or any of the other
resident experts, they will not bother chiming in.
Otherwise, they've been pretty diligent following up with suggestions.
What do you plan to do with your macros that intercept Undo/Redo?
Maybe there's another way to achieve the same result?

I am writing a Word add-in.
Without getting into details, the add-in creates bookmarks, variables
and performs some other operations, all of which have to be synchronized.

Unfortunately, some of these operations are undo-able and if the user
choses to undo them, the document may remain in an inconsistent state
(at least from the add-in's perspective).

Therefore, whenever the user wishes to undo a partial operation, I
need to hijack the operation and iteratively undo the whole group of
operations. Similarly with "redo".

See
http://groups.google.ca/group/microsoft.public.word.word97vba/msg/c5f120a7817f3dbb for details.


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

A

Alex

Hello Peter,

Peter Huang" said:
Hi

So far I think we need to insert macro into document to hook the redo and
undo.

I think you are missing something.
The macros will hook the keyboard and menu operations but not the undo/redo toolbar buttons and dropdowns.


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi Alex,

Sorry for misunderstanding, I will research the issue and update you with
new information ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

Hello Peter,

Peter Huang" said:
Hi Alex,

Sorry for misunderstanding, I will research the issue and update you with
new information ASAP.

Thank you!

By the way, does anybody from MS monitor the microsoft.public.word.vba.* groups?
I have noticed that the post there do not get the same level of attention that you provide here.

Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi Alex,

We will monitor the managed newsgroup queue.
Here is a link about the managed newsgroup.
http://msdn.microsoft.com/newsgroups/managed/

Also based on my research, the Word Object Modal did not expose the
function for us to override the button click function. Even if we add a
event handler to the buttons, but when the event is fired, the buildin
function has been called. That is to say we are just notified, but not
override.

If you still have any concern, I think you may try to contact MSPSS to see
if they have any other idea.
http://support.microsoft.com

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

Hello Peter,

"Peter Huang" said:
Hi Alex,
Also based on my research, the Word Object Modal did not expose the
function for us to override the button click function. Even if we add a
event handler to the buttons, but when the event is fired, the buildin
function has been called. That is to say we are just notified, but not
override.

OK.

If I cannot override it, can I at least invoke a function before and/or after the default behaviour by adding an event handler?
If so, can you give me an example of how to do it?


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi

Based on my research, the Undo/Redo button is a CommandBarComboBox type
which expose the Changed Event only.

Here is my test addin. But since the redo/undo button is kind of special
CommbandBarComboBox, it will have a button, but the button click event is
not exposed by Object Modal, so here we can add handler to the Changed
event which will fired when we click the little arrow beside the button and
then select one item, but it will not fire when we click the button
directly.

Based on my research, I did not find better workaround for this issue, if
you still have any concern, I suggest you contact MSPSS directly to see if
they have any better idea.

http://support.microsoft.com

Thanks for your understanding!

namespace MyWordAddin1
{
using System;
using Microsoft.Office.Core;
using Extensibility;
using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;
using System.Diagnostics;
[GuidAttribute("10F9EBA7-4332-4BA2-9C79-59AC13621BD6"),
ProgId("MyWordAddin1.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public Connect()
{
}

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
Debug.WriteLine("OnConnection");
wdApp = application as Word.Application;
}

public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
Debug.WriteLine("OnDisconnection");
}

public void OnAddInsUpdate(ref System.Array custom)
{
Debug.WriteLine("OnAddInsUpdate");
}

public void OnStartupComplete(ref System.Array custom)
{
Debug.WriteLine(wdApp.CommandBars[1].Name);

foreach(CommandBarControl cbc in wdApp.CommandBars[1].Controls)
{
if(cbc.Id == 128)
{
Debug.WriteLine("Found Control Undo");
cbcbUndo = cbc as CommandBarComboBox;
if (cbcbUndo!=null)
cbcbUndo.Change+=new
_CommandBarComboBoxEvents_ChangeEventHandler(cbcb_Change);
else
Debug.WriteLine("cbcbUndo is NULL");
}
if(cbc.Id == 129)
{
Debug.WriteLine("Found Control Redo");
cbcbRedo = cbc as CommandBarComboBox;
if (cbcbRedo!=null)
cbcbRedo.Change+=new
_CommandBarComboBoxEvents_ChangeEventHandler(cbcb_Change);
else
Debug.WriteLine("cbcbRedo is NULL");
}

}
}

public void OnBeginShutdown(ref System.Array custom)
{
Debug.WriteLine("OnBeginShutdown");
}
private Word.Application wdApp=null;
private CommandBarComboBox cbcbUndo=null;
private CommandBarComboBox cbcbRedo=null;

private void cbcb_Change(CommandBarComboBox Ctrl)
{
Debug.WriteLine("cbcb_Change");
}
}
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Y

Yan-Hong Huang[MSFT]

Hi Alex,

I was reviewing the issue thread. How is everything going? I checked with
Peter already. There are no direct way to workaround it currently. If you
have any more concerns on it, how about using one of your MSDN free support
incidents to contact customer service on it to see whether there is any
better option from support team.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

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