-
Ok, what's wrong with this:
Dim opentxt As Double
Dim parameter As String
parameter = "C:\Program Files\Accessories\WordPad " & App.Path & "\temp.txt"
opentxt = Shell(parameter, vbNormalFocus)
It keeps saying that it can't find c:\Program. I think I might have to use c:\Progra~1\... But I don't know what drive it's going to install in, that's why I have to use App.Path.
Any ideas?
Thanks in advance! :)
-
If you are using app.path I don't think that you need to have the "C:\Program Files\Accessories\WordPad " first, try taking that out. If that does not work try putting a break when you 'parameter' and then view it's contents in the immediate window, and see what is set to 'parameter'
good luck
-
I tend to have problems with the App.Path statement sometimes as well, and for really it seems no good reason. So generally I use this function:
Code:
Public Function AppPath() As String
Dim strPath As String
strPath = App.Path
If Right$(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
AppPath = strPath
End Function
Hope this helps.
-
I need the C:\Program Files\...\Wordpad for the txt file to open in wordpad; otherwise it might open in Notepad. And I already checked the value of parameter, and it gave me the value that I assigned... any other suggestions? PLEASE?!?
-
Code:
Dim opentxt As Double
Dim parameter As String
parameter = "C:\Program Files\Accessories\WordPad.exe " & App.Path & "\temp.txt"
opentxt = Shell(parameter, vbNormalFocus)
Maybe because you forgot the .exe part? It works for me.
-
Thanks everybody, but none of these work for me... :(
-
I think this may have something to do with DOS file names. I get the same errors as you do but the msgbox shows the correct path:
Dim strPath As String
strPath = App.Path
parameter = "C:\Program Files\Accessories\WordPad " & strPath & "\temp.txt"
MsgBox parameter
Is there any spaces in the path you are using?
In WordPad the described Path/File stops if there is a space in strPath. Just like a DOS program I expect. There may be a way to convert the path to a DOS path.
-
In case it's because of the spaces try this:
Code:
parameter = """C:\Program Files\Accessories\WordPad"" """ & App.path & IIf(Right(App.Path,1)="\","","\") & "temp.txt"""
[Edited by Fox on 07-13-2000 at 05:04 PM]
-
thanx everybody, I think Fox's answer worked... :D