Launching WinWedge from Excel Example #2 The
following subroutine does the same thing as the code
above except that it launches the WinWedge
configuration file directly using the Windows API function
"ShellExecute". The advantage of the following method
is that you do not need to know the location of the
WinWedge.EXE program file and you only need to know
the file location for the WinWedge configuration file
that you want to use.
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
Sub LaunchWinWedgeConfig()
Dim WedgeFile As String, X As Long
WedgeFile = "MyConfig.SW3" 'WinWedge
config file name
' assume the
config file is in the same file folder as this
' workbook - if not, code the full path for
the file into
'
the WedgeFile variable and delete the
following line
WedgeFile = ThisWorkbook.Path & "\" & WedgeFile
'
launch the WinWedge configuration file
X = ShellExecute(0, "open", WedgeFile, vbNullString,
vbNullString, 0)
If X < 33 Then '
function failed - warn user and exit
MsgBox "The file: " & WedgeFile & " did
not launch successfully"
Else ' otherise, wait 3 secs for WinWedge
to load
Application.Wait Now + TimeValue("00:00:03")
AppActivate Application.Caption ' set focus
to Excel
End If
End Sub |