Results 1 to 9 of 9

Thread: path...?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Angry

    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!


  2. #2
    Junior Member
    Join Date
    Jun 2000
    Posts
    28
    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
    Using VB 6.0 SP 3
    Bed goes up, bed goes down

  3. #3
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Unhappy

    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?!?

  5. #5
    Guest
    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.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26
    Thanks everybody, but none of these work for me...

  7. #7
    Addicted Member
    Join Date
    Jul 2000
    Location
    Scotland
    Posts
    184
    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.


  8. #8
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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]

  9. #9

    Thread Starter
    Junior Member
    Join Date
    May 2000
    Posts
    26

    Talking

    thanx everybody, I think Fox's answer worked...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width