Results 1 to 6 of 6

Thread: execute an external program

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    It seems that, in effect, there isn¡¯t much difference between the Shell and ShellExecute functions. I have tried both of them and still the problem I proposed in my ¡°call an outside application¡± topic remains. HeSaidJoe has suggested a resolution, but I am stupid enough not to be able to solve it, for I must open a document file in that directory (with a space in it).

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    application¡± topic 'what is it with your fonts....
    that stuff is hard to read when it keeps popping in
    and out.

    Post your code so I can get a better idea of how to deal with the situtation.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    Dosen't somthing like this work ????


    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


    ShellExecute hwnd, "Open", "C:\my documents\my stuff.doc", "", "c:\my documents", 9

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    This works with spaces in the folder name and
    with spaces in the file name.
    Code:
    'put this in a bas module
    '
     Public Declare Function ShellEx Lib "shell32.dll" Alias _
     "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
     ByVal lpFile As String, ByVal lpParameters As Any, _
     ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
     '
     
    
    'Form events
    'open a file with it's associated application
    
    Private Sub Command1_Click()
    '
     Dim sFileName As String, x As Long
      sFileName = "c:\my documents\my special file.txt"
      x = ShellEx(Me.hwnd, "open", sFileName, "", "", 1)
    '=====================================
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    I have succeeded. Thank you, HeSaidJoe and joefoulkes.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    And then there were still problems, which came up with document files having an association different from the default one. For example, on one of my computers ACDSee is installed which is associated with the .BMP files whose default server should have been MSPaint.exe or Pbrush.exe. When I used the ShellExecute function to open a .BMP file, it called up ACDSee with which I could not edit the file. I finally solved the problem with the following code:

    strWinDir = ¡°C:\Windows¡±
    strBmpFile = ¡°C:\Program Files\Microsoft Exchange\Image.bmp¡±

    Shell strWinDir & ¡°\Pbrush.exe ¡° & Chr$(34) & strBmpFile & Chr$(34), vbMaximizedFocus

    Thank you all the same, HeSaidJoe and joefoulkes.

    -- IHailJoe

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