Catch click event button

N

Neron

Hi all,

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

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

Greetz,

Ber
 
J

Jay Freedman

It is possible to catch ("intercept") most built-in Word commands, as
described at
http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.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
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
N

Neron

Hi Jay,

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

I've been trying to intercept an event directly from the control, bu
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 th
Undo-button... :-(

Greetz,

Bert
 

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