Run a VBA function every time 'Undo' is clicked - vba

Is it possible to run a VBA function (Word 2007) every time the user clicks 'undo' (or crtl+z)? Thanks.

You can intercept most built-in commands in Word with VBA. See
Using VBA to Control Built-In Commands in the 2007 Office System.
Try intercepting the EditUndo command.

Related

How to call a VBA-macro in another MS Word document?

in MS Excel I have been distributing a xls-file that contains a macro. From the users "random" current open workbook I have successfully been calling this macro by telling Word in which file to look for it. Like this, when the user clicks a button on the ribbon:
C:\\"'MyExcelFileWithTheMacro.xls'!MyMacroName"
Can I do the same in MS Word?
That is, to call a macro in a Word-file located in any given folder from an instance of Word that has not opened that file?
I have tried, of course, but Word keeps saying it can't find the macro.
The reason I want to do it this way is that it is makes for easy distribution and updating of the macro. Next up is signing the macro. I hope it can be done when doing things this way, but not sure.
No, it's not possible to call and run a macro in any Office application if the file that contains the macro is not loaded in the application interface.
That being said, if you place the macro in a *.dotm template and have the user put the template in the STARTUP folder used by the Word application, then Word will load the template as an "Add-in". And in that case you should be able to access the macro.
Or, if you don't want it in the Startup folder and you have code that automates the Word.Application, anyway, then that code can load the *.dotm as an "Addin", which should make the macro available (and remove it when you're done with it). Research Application.Addins.Load and Addin.Installed in the Word language reference as well as on-line for examples.

Run a 3rd party Excel Add-in from VBA

I want to programatically run a 3rd party Add-in with VBA alone. Im using Excel 2010
Ideally, I'd like to be able to call the functions individually however I don't have any access to the code of the Add-in (it doesn't even appear as a password protected VBA Project it did in Excel 2003).
Hours of Googling has told me this was possible in earlier versions of Excel, either through Application.CommandBars("Add-Ins").Controls("Custom Button").Execute or CommandBars.ExecuteMso("Custom Button") - AFAIK, the latter now only works with in-built functions.
This custom button also appears in the 'Right-Click' menu so could possibly be run with some sort of SendKeys implementation. This is however, clearly far from ideal.
I'm pulling my hair out over this - any help would be greatly appreciated.
Depending on how it has been added to the menu, this may work:
Application.Commandbars("Cell").Controls(Application.Commandbars("Cell").Contro‌​ls.Count).Execute
which simply executes the last control. Also this should work by the control caption:
Application.Commandbars("Cell").Controls("the button caption").Execute

Call SAP Transaction ME33K with VBA Code. How?

I am desperately looking for a code to call an agreement out of vba in ME33K in SAP.
I have the agreement number, so I want to this number to be called in ME33K and pop up the SAP GUI.
Is there a way to do it? Can someone provide a code?
You should be able to do that with VBS from SAP itself (and not with VBA from Excel):
Go to the script recdorder: ALT+F12 > "Script Recording and playback", press the recording (red) button
Perform all you actions: go to your YSD033 screen, pull the variant, run the report, save it in Excel, close transaction.
Then stop recording.
The script (a VBS program) will be saved in your default SAP directory (but you can change this location esaily).
To run the script either play it from SAP (ALT+F12, etc except that instead of recrding it, play it) or you can also run it from Windows (if SAP is open) by double clicking the vbs file.
Mario Rappi on Feb 26, 2010 7:18 PM
http://scn.sap.com/thread/1619517

Input values into an Input Box that was called by another Macro

I am writing a VBA macro that calls some macros from other Excel workbooks. These Macros are protected and I do not have the ability to see or modify their code. In one of the macros, an InputBox is called.
Is there a way to automatically trigger the OK button so that the InputBox does not load up (or pops up and then closes without prompting the user)? I can live with the default value for the input box to be used (though I'd also like to modify it if possible).
Please let me know if more information is needed - thanks in advance.
Have a look at example:
Sub MyMacro()
Call MacroInDifferentWorkbook
'here code to catch InputBox
End Sub
If you're trying to do that in that way, the answer is NO, you can't catch InputBox from MacroInDifferentWorkbook. It was well explained here:
Simulating Multithreading in VBA using Excel
Multithreaded VBA – An Approach To Processing Using VBScript

Word 2007 VBA - Load macro on Document New via Addin

Good morning good folks! :) So here's what I'm trying to do. I've got this design template that I want to add to all new documents that are being created in Word 2007. In additon, I've got an addin in the form of a dotm file that's loaded everytime Word starts. This addin is located in the Startup folder on each computer. This is not a COM addin btw.
Now, I've tried a few things out. First of all, I've tried the Document_New and Document_Open handlers, as well as the AutoExec and AutoOpen handlers in the addin dotm-file. Document_New did not trigger anything when I start a new document. Document_Open didn't either. But AutoExec did trigger, but I can't apply the design profile in that trigger because there is no document open at that point.
So, how do I do this? I do not want to mess with the normal.dot at all, so I'm trying to avoid that and keep all code in the addin and perhaps a few macros in each template. But that's it. I want to keep it clean. Any ideas?
Are you hooking in to events at the Application level? or just at the document level? You need a "with events" reference to the Word application in order to trap the events you're interested in.
See here: http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm