Microsoft word

There is visual basics in microsoft word and i want to know how to program it to open another program.  i know some visual basics.  I tried  this:

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Private Sub Command1_Click()
    ShellExecute Me.hwnd, "open", "C:\Program Files\Acceleration Software\Net Butler\NetButler.exe", "", "", 5 'SW_SHOW = 5

just everythin on their proper lines (this form cuts them up)

So, this answer wont work so don't give it to me....thanks...
mrcool4444Asked:
Who is Participating?
 
mannoConnect With a Mentor Commented:
From the Word help:

Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1)      ' Run Calculator.

0
 
gkanaanCommented:
This definitly works in VB, i use it all the time... Shell is a built in function in VB, type Shell in the VB editor, go to it's beginning and press F1, you'll get more help on it

hWnd=Shell("C:\blah.exe", vbNormalFocus)

if Shell succeeds it will return a handle to the program that just ran

ShellExecute should also run, but it is a more complicated function that can do more complicated stuff then simple Shell. I use it in one of my software to make VB open a webpage in the user's default browser...
0
 
mrcool4444Author Commented:
okay, you are not understanding me....i am talking about visual basics IN microsoft word.  what you told me above doesn't work also just to let you know.  i am going to reject your answer, but if you can make it so it will work in microsoft word, i will accept it.
0
 
mrcool4444Author Commented:
That works.  Thank you!
0
 
mrcool4444Author Commented:
That works.  Thank you!
0
All Courses

From novice to tech pro — start learning today.