A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Catch click event button



 
 
Thread Tools Display Modes
  #1  
Old March 22nd, 2010, 04:37 PM
Neron Neron is offline
Experienced Member
 
First recorded activity by OfficeFrustration: Jul 2005
Posts: 34
Default Catch click event button

Hi all,

I was wondering...
Is it possible to "catch" a click-event on a BuildIn Offie Button? In order to execute your own VBA-code?

e.g. I want to be able to catch the "Undo" button in order to execute a piece of macro code in stead of just "Undoing" only the last action.

Greetz,

Bert
  #2  
Old March 22nd, 2010, 07:10 PM posted to microsoft.public.word.docmanagement
Jay Freedman
external usenet poster
 
Posts: 9,488
Default Catch click event button

It is possible to catch ("intercept") most built-in Word commands, as
described at
http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm.

In this case, the macro you need to write is named EditUndo, as in

Public Sub EditUndo()
' do your stuff here
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Mon, 22 Mar 2010 12:37:07 -0400, Neron
wrote:


Hi all,

I was wondering...
Is it possible to "catch" a click-event on a BuildIn Offie Button? In
order to execute your own VBA-code?

e.g. I want to be able to catch the "Undo" button in order to execute a
piece of macro code in stead of just "Undoing" only the last action.

Greetz,

Bert

  #3  
Old March 23rd, 2010, 10:03 AM
Neron Neron is offline
Experienced Member
 
First recorded activity by OfficeFrustration: Jul 2005
Posts: 34
Default

Hi Jay,

Thanks for the reply, but unfortunately this is not the macro / event I hoped for.
The EditUndo-macro just intercepts the [Ctrl]+[Z] key press event, it doesn't respond to the "Undo-button" in the Command Bar / Quick Access Toolbar.

I've been trying to intercept an event directly from the control, but unfortunately I can't seem to get this one working:

Public WithEvents m_Undo As Office.CommandBarComboBox
Public WithEvents m_Print As Office.CommandBarButton

Private Sub Document_New()
Set m_Undo = Application.CommandBars.FindControl(6, 128)
Set m_Print = Application.CommandBars.FindControl(1, 4)
End Sub

Private Sub Document_Open()
Set m_Undo = Application.CommandBars.FindControl(6, 128)
Set m_Print = Application.CommandBars.FindControl(1, 4)
End Sub

Private Sub m_Print_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
Call MsgBox("I can print", vbOKOnly)
End Sub

Private Sub m_Undo_Change(ByVal Ctrl As Office.CommandBarComboBox)
Call MsgBox("I can undo", vbOKOnly)
End Sub

Intercepting the Print button works just fine, but intercepting the Undo-button... :-(

Greetz,

Bert


Quote:
Originally Posted by Jay Freedman View Post
It is possible to catch ("intercept") most built-in Word commands, as
described at
http://www.word.mvps.org/FAQs/Macros...tSavePrint.htm.

In this case, the macro you need to write is named EditUndo, as in

Public Sub EditUndo()
' do your stuff here
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Last edited by Neron : March 23rd, 2010 at 10:49 AM.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:03 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.