
How can I add an EXE file to a Word toolbar?How can I create a button in Word to launch a custom application? Microsoft Word is a very powerful and flexible program, especially when it comes to it toolbars or CommandBars, as Microsoft refers to them. There are two different methods of creating having a button point to an outside program. One is by using a hyperlink and the other is by using a Visual Basic for Applications (VBA) macro. Both are simple to the do and the only difference is in how the external program is called, which also changes how Word reacts in regards to security. When using a hyperlink, Word treats it as coming for an unknown source and will display warnings asking if you really want to launch the program. It's the same as when you click on a EXE file from inside Internet Explorer, a warning displays telling you of the dangers of using an unknown program. With a VBA macro, all the security settings are based on the trustworthiness of the macro itself. Once you allow the macro to run, everything it does is deemed to be safe, so the external program will launch with no warnings. Safety issues aside, I'm going to focus on the VBA method since I think most folks would only be adding an EXE to their Word toolbar that they already trust and would become annoyed with the extra warnings rather quickly. Also, although I'm using Word here, these steps can be repeated in just about every other Microsoft Office application. The steps outlined are for Word 2003 and may vary slightly for other versions of Word.
Sub RunNotepad() Shell Pathname:="C:\WIndows\Notepad.exe", _ WindowStyle:=vbNormalFocus End Sub
The Shell command supports several different options for how the external program is opened. View the VBA help file for more information.
Category is Microsoft Office
(Article #3)
Comments
This site is incredible!
This site is incredible! It's amazing the questions you get asked and you always come up
with the answer. I've just got to help you stay cool by buying you a
Snoball!
I do have a comment, now that you mention it!
|
|