Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ShellExecute access 2007 Windows 7 Pro -launch another program with argurments 1

Status
Not open for further replies.

Emblem1

Technical User
Jan 11, 2007
77
0
0
US
I am having difficulty figuring out how to correctly launch a program with arguments in the launch script I am using Win 7 64 bit Pro, and Access 2007. Pilfering code from the 'net, and attempting to modify existing code in my DB has proved fruitless to make this work. I am a vba novice.

A program sits here: C:\Program Files (x86)\EDI ECcom\Eccom.exe
the argurments are to add an IP address "switch" to the launch script: "/ipad=192.168.1.10"

Here is the exsiting code. I get an launch error stating it cant open file '/ipad=192.168.1.10'
Other attempts have brought up the 'find program' dialog ....

It's not an issue with the app, because manually editing the shortcut works fine.

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 Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWDEFAULT As Long = 10

Private Sub RunShellExecute(sTopic As String, _
sFile As Variant, _
sParams As Variant, _
sDirectory As Variant, _
nShowCmd As Long)

Dim hWndDesk As Long
Dim success As Long

'the desktop will be the
'default for error messages
hWndDesk = Application.hWndAccessApp

'execute the passed operation
success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory, nShowCmd)

'This is optional. Uncomment the three lines
'below to have the "Open With.." dialog appear
'when the ShellExecute API call fails
If success < 32 Then
Call Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile, vbNormalFocus)
End If



Dim sTopic As String
Dim sFile As String
Dim sParams As String
Dim sDirectory As String

'set default setting to be used
'if not specifically required
sTopic = "Open"
sFile = vbNullString
sParams = vbNullString
sDirectory = vbNullString

sFile = "C:\Program Files (x86)\EDI ECcom\Eccom.exe"
sFile = sFile & " /ipad=192.168.1.10"


Call RunShellExecute(sTopic, sFile, sParams, sDirectory, SW_SHOWDEFAULT)

End Sub


Thanks for any help!!!!
 
sFile = "C:\Program Files (x86)\EDI ECcom\Eccom.exe"
sParams = "/ipad=192.168.1.10
 
Ugh! Figures. I thought it was something like this. I played with that too, but I must have had my syntax off..... geez. Thanks a bunch!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top