|
-
April 2nd, 2005, 01:20 PM
#1
ShellExecute Help
Hello, I am having problems with the following statement:
Code:
slAppToRun = ShellExecute(0, vbNullString, "WordPad", App.Path & """\Extension Table.txt""", vbNullString, vbNormalFocus)
This statement works fine if my App.Path is C:\. But when my App.Path is C:\Documents and Settings\Administrator\My Documents\ it doesn't work.
I get a message box from word pad telling me:
C:\Documents
Cannot find this file
Please verify that the correct path and file name are given
Is the error because there are spaces in my path string? How can I correct this?
Thanks very much!
~Steph
-
April 2nd, 2005, 01:52 PM
#2
Re: ShellExecute Help
It has nothing to do with the spaces. All strings use spaces as characters. Any string that you declare can have as many spaces as you want in it.
You have to remember that the ShellExecute has the path set in it as a string called.
Code:
slAppToRun = ShellExecute(0, vbNullString, "WordPad", "Extension Table.txt", App.Path, vbNormalFocus)
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 3rd, 2005, 04:12 AM
#3
Re: ShellExecute Help
Hi Steph,
I have got this error before and the reason for this error is using single backslash...
try it this way
Code:
Dim sPath As String
sPath = Replace(App.Path, "\", "\\")
slAppToRun = ShellExecute(0, vbNullString, "WordPad", sPath & """\\Extension Table.txt""", vbNullString, vbNormalFocus)
hope this helps
--Shuja
Edit:
Corrected the code....Sorry for that..oops
Last edited by vb_the_best; April 3rd, 2005 at 04:14 AM.
-
April 3rd, 2005, 09:19 AM
#4
Re: ShellExecute Help
Question vb_the_best,
The path/directory of the file you are trying to execute is right in the API call itself. Why not just put it there instead of putting it in the file string call in the API call? Why not just do my solution which requires no string combinations and follows the API's primary usage???
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
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 4th, 2005, 01:39 AM
#5
Re: ShellExecute Help
Hi Peejavery,
Nothing wrong with your code, I was just showing the other way of doing it..
There can be hundered different ways of doing a single thing.. so people give different solutions...
Shuja
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
|