Results 1 to 7 of 7

Thread: Wordpad execute?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Location
    CWMBRAN,WALES,UK
    Posts
    146

    Question

    I have a 'Readme' text document that accompanies my app.
    I want to open 'Readme' from Form Activate so that the text file opens in Notepad and is the first thing the user sees before using the app.
    Assuming the file is Readme.txt and it is on app.path, how can I do this.
    (I don't want to create a form with the info on it)

    The code would be much appreciated
    GRAHAM

  2. #2
    Guest
    One method is to use the Shell Command and then use the SendKeys to open the file. Make a Form with a CommandButton on it and put the following code into the Commandbutton. Make sure that you have a file in your C:\ directory. Call it Readme.txt, and make sure to put some text in it!!

    Code:
    Private Sub Command1_Click()
    
       ' Open Notepad 
       RetVal = Shell("C:\windows\Notepad.exe", vbNormalFocus)
       SendKeys "%"              ' Send the ALT button
       SendKeys "{DOWN}"         ' Send the down key
       SendKeys "{DOWN}"         ' Send another down key
       SendKeys "{ENTER}"        ' Send the enter key
       SendKeys "C:\Readme.txt"  ' The file you want to open 
       SendKeys "{ENTER}"        ' Send enter to select it.
    
    End Sub
    Then the text in your file should appear.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Location
    CWMBRAN,WALES,UK
    Posts
    146
    Thanks for responding Megatron, but that's not what I'm looking for. In this particular instance the app. will be
    running from A:\, and when FrmMain activates I want Notepad to open on top of it with the .txt file opened, if you follow my drift.

    Thanks again
    GRAHAM

  4. #4
    Guest
    Code:
    'this code can either be for txt files or any file including exes
    ffile = "C:\Windows\Win.ini"
    Shell "Notepad.exe " & ffile & "", vbNormalFocus
    Is that what you were looking for?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Location
    CWMBRAN,WALES,UK
    Posts
    146
    Thanks for responding Matthew, I think I,ve got the general idea now, so I,ll experiment and see what happens. I thought there was an API that handled this, still never mind, I should be able to work something out.

    Thanks again
    GRAHAM

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You may want to use the ShellExecute API instead so it starts the text file in whatever the user has as the .txt Open with. What if they don't have Notepad.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Location
    CWMBRAN,WALES,UK
    Posts
    146
    Yes Ed, you're right.
    That's why I was hoping for a bit of demo' code that gave the API and how it would be called relevant to my case.
    Perhaps I should have been a bit more specific in my post.
    Can anyone help me out on this one.

    Cheers
    GRAHAM

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