|
-
Oct 18th, 2010, 01:40 AM
#1
Thread Starter
New Member
[RESOLVED] How to exe files in form
How do i open exe files through command button, thanks for your help
-
Oct 18th, 2010, 01:44 AM
#2
Re: How to exe files in form
Search the Forumfor ShellExecute
-
Oct 18th, 2010, 01:52 AM
#3
Thread Starter
New Member
Re: How to exe files in form
-
Oct 18th, 2010, 02:38 AM
#4
Thread Starter
New Member
Re: How to exe files in form
Hi i have tried ShellExecute "c:/program.exe"
and i have tried Shell "c:/program.exe"
and both do not work what im i doing wrong thanks
-
Oct 18th, 2010, 07:10 AM
#5
Re: How to exe files in form
Welcome to VBForums 
That depends entirely on what "do not work" means in this case (it nearly always means something different). For example, if there is an error message, it will briefly explain what you are doing wrong.
One obvious issue with what you posted is that you are using / (for unix and the web) when you should be using \ (for Windows).
-
Oct 18th, 2010, 11:25 AM
#6
Thread Starter
New Member
Re: How to exe files in form
this is my code, please help its not working
Code:
Private Sub Command1_Click()
Shell "C:\Documents and Settings\andrew\My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe"
End Sub
-
Oct 18th, 2010, 11:56 AM
#7
Re: How to exe files in form
Try
vb Code:
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 Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Documents and Settings\andrew\ " & _
"My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe", _
vbNullString, "C:\", SW_SHOWNORMAL
End Sub
-
Oct 18th, 2010, 12:08 PM
#8
Thread Starter
New Member
Re: How to exe files in form
i have tryed it and still dose not work, maybe im doing somthing wrong.
-
Oct 18th, 2010, 12:09 PM
#9
Re: How to exe files in form
What does "not work" mean? Are you getting an error?
-
Oct 18th, 2010, 12:19 PM
#10
Thread Starter
New Member
Re: How to exe files in form
it just high lights it in blue and says Compile Error and Syntax Error
-
Oct 18th, 2010, 12:55 PM
#11
Re: How to exe files in form
Both your and Hack's code compile OK -what exactly is bing highlighted in blue ?
-
Oct 18th, 2010, 01:06 PM
#12
Thread Starter
New Member
Re: How to exe files in form
Im i doing this right
Code:
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 Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hWnd, vbNullString, "C:\Documents and Settings\andrew\ " & "My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe", _
16#
vbNullString , "C:\", SW_SHOWNORMAL
End Sub
-
Oct 18th, 2010, 01:14 PM
#13
Re: How to exe files in form
You must get rid of the blank lines between lines that are continued with the "_" character:
Code:
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 = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Documents and Settings\andrew\ " & "My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe", _
16#, vbNullString, "C:\", SW_SHOWNORMAL
and BTW this looks nothing like the code you posted in Post #6, were we meant to guess what code you were actually using ?
-
Oct 18th, 2010, 01:22 PM
#14
Thread Starter
New Member
Re: How to exe files in form
Hi it high light ShellExecute and an error comes up and says Compile Error or Arguments or Invalid Property Assignment.
and this is my code
Code:
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Documents and Settings\andrew\ " & "My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe", _
16#, vbNullString, "C:\", SW_SHOWNORMAL
End Sub
-
Oct 18th, 2010, 01:25 PM
#15
Re: How to exe files in form
What's that 16# parameter? You're passing 7 parameters and the function only takes six. Try
Code:
ShellExecute Me.hwnd, vbNullString, "C:\Documents and Settings\andrew\My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe", vbNullString, "C:\", SW_SHOWNORMAL
Last edited by baja_yu; Oct 18th, 2010 at 01:26 PM.
Reason: typo
-
Oct 18th, 2010, 01:25 PM
#16
Re: How to exe files in form
remove this: 16#,
(which is part of the line numbering from Hack's post, and you haven't got any of the other numbers)
-
Oct 18th, 2010, 01:26 PM
#17
Re: How to exe files in form
What is the "16#" in your line of code? That was never there before. Refer to your own Post #6 in this thread.
-
Oct 18th, 2010, 01:29 PM
#18
Thread Starter
New Member
Re: How to exe files in form
ok thanks all ove you it works thanks agine
-
Oct 18th, 2010, 04:51 PM
#19
Re: [RESOLVED] How to exe files in form
Shell() would have worked fine. All that was needed was to use quotes around the file path because of the spaces in it:
Code:
Private Sub Command1_Click()
Shell """C:\Documents and Settings\andrew\My Documents\vb6.0\OS001\MXPWord2010\mxpword2010.exe"""
End Sub
I'm not sure why so many people want to use an API call when it isn't required.
-
Oct 18th, 2010, 05:16 PM
#20
Re: [RESOLVED] How to exe files in form
I suspect, in this case, it's because we were anticipating the next question......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|