Results 1 to 6 of 6

Thread: Shell command........

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    84
    If I wanted to open up a text file with notepad - is there a way to do that in one step with out sending keys to notepad to open the file...

    Something like: Shell "notepad.exe +myfile.txt".

    Thanks.... I can't find any info on this in my books.

  2. #2
    Junior Member
    Join Date
    Aug 2000
    Posts
    27
    Code:
    Shell "Notepad.exe FileName", vbNormalFocus

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    84
    that was simple.....

    thanks

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up ShellExecute API

    This will better, let the OS use the default textfile browser, instead you specified in the Shell function.

    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:\myfilen.txt", vbNullString, "C:\", SW_SHOWNORMAL
    End Sub


  5. #5
    Guest

    Re: ShellExecute API

    Chris, actually, the ShellExecute api function will load the text file with the default application it is set to use.
    So say the user has something else loading a text file, ShellExecute will load that program instead of notepad.
    Therefore, in this case, if he wants to have the text file loaded in Notepad, the Shell function should be used .

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    yap, Matthew you're right, the SelfExecute will base on what the user have set in the registry for a particular file type. But will the API provided a better performance?

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