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




-- 
Neron
0
Neron
3/22/2010 4:37:07 PM
word.docmanagement 5542 articles. 2 followers. Follow

2 Replies
1783 Views

Similar Articles

[PageSpeed] 48

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        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
<Neron.5ed6667@officefrustration.com> 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
0
Jay
3/22/2010 7:10:35 PM
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


Jay Freedman;3681930 Wrote: 
> 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        FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
> 
> > > >




-- 
Neron
0
Neron
3/23/2010 10:03:24 AM
Reply:

Similar Artilces:

Unhiding/Hiding right click options
I wanted to copy a sheet from an excel file and paste to another file. The problem is, when I right click on the sheet name, the option for "Move or Copy..." has been greyed out. Is this because the sheet has been protected? ... How can I do this type of protection for spreadsheets I create? ... Where only certain functions are greyed out... Thanks! ... LavaDude If you protect the workbook, you can see this option greyed out. Tools|Protect|Protect workbook Is how you would set it. If you see "Tools|Protect|unprotect workbook", then it is protected. You may...

XP Style button using MFC 4.2
Hi, I am using Visual C++ 6, MFC 4.2. Windows XP SP2. My problem is, how could I get the XP Style buttons on the dialog. If i dynamically create the button using CreateWindow() the button still looks same. I've tried 'Button Controls' article on MSDN but no luck. Could anyone help me? Thanks, Fahad Themes are handled by the system, and not on a button-basis. The way to give your application running on XP the themed look is to include a manifest resource. The resource can either be a resource compiled into your EXE or it can be a separate file in the same directory as your ...

Virus Warning when Hyperlink is clicked
Hello, My compay uses an intranet for various forms and documents. The main page uses hyperlinks to access the forms or documents placed elsewhere on the network. This doesn't occur all the time, but only for a few files. When a user clicks on a link, a warning appears that states: "Opening File Path: path to filename Some files can contain viruses or otherwise be harmful to your computer. It is important to be certain that this file is from a trustworthy source. Would you like to open this file?" I understand that this occurs in Microsoft Office and I can't...

Catch WM_SIZE
Hi, How to catch the WM_SIZE message of a control created dynamically. I mean : BOOL CMyDialog::OnInitDialog() { CDialog::OnInitDialog(); // m_MyControl derived from CWND m_MyControl.Create( NULL, _T(""), WS_VISIBLE, CRect(10, 10, 0, 0), this, 1 ); } LRESULT CMyDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_SIZE : // Catch this message but when it is m_MyControl that is resizing. } } Regards, "Erakis" <Erakis@discussions.microsoft.com> wrote in message news:5BC2F5F0-D19B-4B3E-9881-E...

Option Button #3
1. I have added an option button. It is Surgery Yes (this option is numbered 23) or Surgery NO (this option is numbered 24). 2. B8 is the cell number. 3. I have formatted another cell with the formula =IF(B8=1,"Surgery YES","Surgery NO") per the instructions of Microsoft. 4. However, even if I change to the number 23 or the number 24 following the = sign, the anwer is always Surgery NO even if I toggle between both of the selections. 5. I would appreciate your help concerning this issue. I am trying to make the formula cause the answer to be the dotted option. Hi...

Worksheet_Change Event
Hi, In an attempt to protect my data validation from being deleted, I hav written the following code. However, it seems to run into a 1004 erro and a circular reference that Excel cannot list. Does anybody kno where I am going wrong? More importantly, is this the right approach? code: -------------------------------------------------------------------------------- Private Sub Worksheet_Change(ByVal Target As Range) Dim DataRange As Range Dim c As Range Dim mycount As Integer Worksheets("Sheet1").Unprotect "123456" If Range("F12:G21").SpecialCells(xl...

Adding Calendar Items via Click
On some web sites such as eVite.com, it is possible to add an item to your Outlook by simply clicking a link. What is the magic file extension that will invoke Outlook? What is the format of the file for the calendar item? I couldn't seem to find the right words to search for in support.microsoft.com. Thanks. those are icalendars and it can be opened in notepad. if you have one of the items downloaded, open it in notepad or select an event in outlook and choose actions, send as icalendar. Save the resulting attachment to disk and open it in notepad. see http://www.imc.org/pdi/ ...

How to get ID of a button & bitmap in a BitmapButton???
Hii all, I am using BitmapButtons in my application and I want to get the ID of the button aswell as the bitmap placed on it using a CWnd pointer to it.If this is not feasible please do help me with how to get a handler to button & bitmap so that I could use the GetDlgCtrlID() function to retrieve the button/bitmap ID’s. A big Thanxxxxxxxxxxxx in advance, Gov. ----- Well if you have a CWnd pointer to the Button. (I think you answered your own question on this one) pButton->GetDlgCtrlID(); or GetDlgCtrlID(pButton->m_hWnd); As far as the Bitmap ID goes, that information is not ...

How to open a form by clicking a button made in the isv.config
Hi, I made a new entity "mycontacts" that has a few forms. I also made a button in the isv.config under the entity "account". What I want is, that when I click that button, a form of mycontacts(showing also the accounid) will be opened. Are isn't this possible ? Thanks in advance . Climber You can add the following javascript to the button: openObj(crmForm.all.new_accountid.DataValue.type, crmForm.all.new_accountid.DataValue.id) Replace the new_accountid with the proper name of the account field This should work (haven't checked it though). However this i...

Catch all email account
is there a way to set up a catch all email account with exchange 2003. Yes i know the implicaitons of doing this but i believe it is the only way to get this person to realize it is not a good idea after a day or two. In news:uu4FR3XHHHA.924@TK2MSFTNGP02.phx.gbl, Andrew Mallette <andrewm270@aol.com> typed: > is there a way to set up a catch all email account with exchange 2003. > Yes i know the implicaitons of doing this but i believe it is the only > way to get this person to realize it is not a good idea after a day > or two. Check out MailBasket at www.turbogeeks.com. ...

catching VK_SPACE in a CHotkeyCtrl
hi all, when i create a CHotKeyCtrl ( even in a new and empty project in an empty dialog) i cannot catch any VK_SPACE key combination, eg if i press Ctrl+Space the hotkey control immediately shows "None" instead. Also the "Del" key cannot be handled. any ideas Peter ...

Start Button
Has migrated to top left of screen, along with task bar. How to get it back to lower left, please Thanks -- Roger "rogeepete" <arebarr@yahoo.com> wrote in message news:04D59EC3-493C-451D-B332-051396002E40@microsoft.com... > Has migrated to top left of screen, along with task bar. > > How to get it back to lower left, please > > Thanks > -- > Roger Put mouse cursor on it and click and hold then drag it back down to bottom On Sun, 23 May 2010 19:41:01 -0700, rogeepete <arebarr@yahoo.com> wrote: >Has migrated to ...

questions about CToolbarCtrl buttons
Hi, I have a couple questions about buttons in CToolbarCtrl. Here is the code (It is from the KBBar example): NUM_TOOLBAR_BUTTONS = 4; COMBO_IDX = 3; if (!CToolBarCtrl::Create(DEFAULT_TOOLBAR_STYLE, rcClientParent, pWndParent, IDR_IETOOLBAR)) return false; SetButtonSize(CSize(24, 24)); AddStrings("Go\0Stop\0Options\0"); if (AddBitmap(3, IDR_IETOOLBAR) == -1) { DWORD dwError = ::GetLastError(); return false; } TBBUTTON tbs[NUM_TOOLBAR_BUTTONS]; for (int i = 0; i < NUM_TOOLBAR_BUTTONS; i++) { tbs[i].dwData = 0; tbs[i].fsState = TBSTATE_ENABLED; tbs[i].f...

Click to insert picture problem
I have Office 2007 and Windows 7(x64). I've been clicking on the picture icon, the lower left icon of the 4 icons. I don't know what I did but suddenly the window that opens to my pictures filled the entire screen. The upper right corner has only the red X button, not the maximize and minimize buttons. When I put the cursor on either the left or ride side or bottom, it changes to the double-headed arrow which one usually uses to drag to change the size of the window. But it doesn't work. I've tried rebooting to no avail. How do I get the window back to a small...

how to catch key stroke events "globally"
How do can one catch key pressed events "globally"? By that, I don't mean by the main app, I mean, say for example you want to create a "panic button". So that say you're running what ever app (not the one you made), and you want to catch/use the escape key as your panic button. The user presses the escape key, and all windows become hidden. The first problem, is catching the escape key, the second is iterating all top level apps/windows. "Martin Ortiz" <martinortiz@optonline.com> skrev i en meddelelse news:u6eERqJ8DHA.488@TK2MSFTNGP12.phx.gbl... ...

Catching mail for disable user with no mailbox
I have a user ("olduser') in AD who has been gone for a year and never had an Exchange mailbox (pre-migration). As of today, I want to have any inbound mail to "olduser" captured by the SMTP virtual server and sent to another user. I simply gave "otheruser" an additional address of "olduser@domain" and delivery works internally via Exchange, but external senders get a reply: Remote host said: 550 5.7.1 Requested action not taken: mailbox not available. I expect I could delete the old user from AD, but that's not permitted right now. Thanks...

Prevent clicking on a cell
I want to run the code below to prevent a range of cells from being selected if the Range("Q7") = 1. I have all cells on the worksheet locked but the user must be able to click on the locked cells to trigger a userform so I have to check Select Locked Cells. So is there any way make the Range("B5:C5") unselectable? If Range("Q7") = 1 Then Range("B5:C5").Locked = True End If Hi, >So is there any way make the > Range("B5:C5") unselectable? No but you can stop them staying there. Private Sub Worksheet_...

"Map" button
Does the "Map" button exist in 2003 EXCELL Hi no, MS has disconitnued this support with Excel 2002 -- Regards Frank Kabel Frankfurt, Germany "NLeites" <NLeites@discussions.microsoft.com> schrieb im Newsbeitrag news:A47AFEDE-097D-4BDC-B1F5-CD902D880C95@microsoft.com... > Does the "Map" button exist in 2003 EXCELL You must now purchase MapPoint program which interfaces with Office apps. Gord Dibben Excel MVP On Thu, 11 Nov 2004 23:19:40 +0100, "Frank Kabel" <frank.kabel@freenet.de> wrote: >Hi >no, MS has disconitnued this suppo...

Pay Per Click is a Waste of TIME...
http://getpaidforeveryvistor.googlepages.com/home is the new way for publishers to get paid off per visitor on there website... So every visitor you make money not per click. And now become an affiliate while there is still time.. Decide for yourself>>> http://getpaidforeveryvistor.googlepages.com/home "t8bpfc1f" <saeui3iaiy@gmail.com> skrev i meddelelsen news:a4ca063c-b9d2-4d07-ad0e-cc2e23ca5cee@b1g2000pra.googlegroups.com... > http://getpaidforeveryvistor.googlepages.com/home is the new way for > publishers to get paid off per visitor on there website... ...

What am I catching?
I've got a piece of code, looks something like this : try { savetheworld(); } catch(CException* pe) { telltheuser(); } catch(...) { panic(); } The only thing I ever throw are CExceptions (or classes derived from CExceptions), I've even done _set_se_translator() so I capture C structured exceptions (like our good friend 0xC0000005) and turn then into CExceptions that I throw. And yes, they are pointers to CException objects that I've new'ed up, not the objects themselves. So why is it, every once in a while, I catch something that isn't a CException? Now I realize that&...

Group Controls For One Event
I would like to be able to group a bunch of text boxes on my form so that if something changes in any of them I can use the onchange event for the group and not have to add code for all textboxes. Is this possible? Thanks. There are different ways to achieve that. Are the specified controls al textboxes or.. what makes the distinction. The 'tag' property of the control is often used for checking groups of controls. Example: alle the controls that have "hide" in them should be hidden after a certain action. set every tag of the specified controls t...

OnVScroll event not calling for CSliderCtrl
Hi, I have created my own derived CSliderCtrl class. Objects of this class respond to OnKeyDown, OnKeyUp, OnKillFocus, but when I reposition the slider OnVScroll is not being called. I create my objects as follows - CSequencerSlider* pSlider[4]; for(int i=0;i<4;i++) pSlider[i] = new CSequencerSlider; for(int i=0;i<4;i++) { pSlider[i]->Create(WS_VISIBLE | TBS_VERT, CRect(12, 20+i*125, 38, 130+i*125), this, 0); pSlider[i]->SetRangeMin(0); pSlider[i]->SetRangeMax(100); pSlider[i]->SetRange(0, 100); pSlider[i]->SetPos(50); } This all works fine. My .cpp and ...

Virus checking via double-clicking
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel At one time double clicking an Office file icon on the Mac by-passed virus checking. If I double click an Office file icon on my Mac, will Mac Office 2008 check for viruses automatically before opening the file for use by the Office application? On Tue, 2 Jun 2009 09:20:19 -0400, trying_to_work@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.5 (Leopard) > Processor: Intel > > At one time double clicking an Office file icon on the Mac by-passed virus > checking. If I double cli...

100 Radio Buttons Per Contact
Because of the nature of our business, we have multiple monthly communications with our customers/contacts. Depending on the contacts authority/importance in their company, each contact can receive around 100 communications from us a month. Communications are all sent different ways, mail, fax, email, personal call. Is the only way to designate who should receive which communication, to put 100 radio buttons on a tab at the contact level and select the appropriate ones? There has to be a better way than 100 radio buttons on a tab at the contact level. The screen is going to look like...

Recover newsgroup from catching up
I've got a newsgroup where I used the Catch Up option. I now find myself interested in retrieving the messages that were dropped in doing so. How can I completely reset the newsgroup? -- David Trimboli http://www.trimboli.name/ While in the newsgroup: View | Current View. Make sure Show All Messages and Group Messages By Conversation are checked. Tools | Options | Read. Uncheck: Get XXX headers at a time. Right click on the newsgroup in the Folder Tree | Properties | Local File | Reset. Switch to another folder and then back and all available messages will be dow...