VBA also has a Shell method that can launch executables without the
Wscript.Shell. It does require the full path to the executable file, though.
For the calculator, the macro would be
Sub RunCalc()
Shell "c:\windows\system32\calc.exe", vbNormalFocus
End Sub
Also note that if you want to put a button on a toolbar (rather than on a
userform), the first line should start with Sub (or Public Sub, but Public
is the default and can be left out) and not with Private. Procedures that
are marked Private won't appear in the list of macros in the Customize
dialog, which makes it hard to assign them to toolbar buttons.
--
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.
alborg wrote:
> Hi S:
>
> Just place a module with a macro such as this-
>
> Private Sub CommandButton2_Click()
> Dim WshShell As Object
> Set WshShell = CreateObject("Wscript.Shell")
> WshShell.Run "Calc"
> Set WshShell = Nothing
> End Sub
>
> You can also do other API callups, s.a.-
>
> -- WshShell.Run "NotePad" (or "NotePad C:\MyTrains.txt" to bring up
> a file)
> -- WshShell.Run "Explorer"
>
> Cheers,
> Al
>
> "SGangs" wrote:
>
>> How to add Calculator as an icon on the Tool Bar of MS Word 2003 for
>> easy access.
>>
>> Thanks in advance..