Results 1 to 10 of 10

Thread: Need help opening CHM file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    13

    Need help opening CHM file

    Please bare with me, I am very new to VB. I have a help file named help.chm and this is in the same directory as all of my VB project files. On my main form, I have a command button named cmdHelp that when clicked, I would like it to open the help.chm file. Could someone please let me know what code I need to place in the click event? All help is greatly appreciated!!!
    Bryan

  2. #2
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475
    Well if you want it to open in something like notepad you can do something like this:

    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 Sub cmdHelp_Click()
    ShellExecute 0&, vbNullString, "notepad", "C:\Location\Of\File\help.chm", vbNullString, vbNormalFocus
    End Sub
    If my post was helpful please rate it

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    13
    I would prefer it not to open in notepad. Id just like it to launch the help file I compiled. Any other ideas?

    Bryan

  4. #4
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475
    Code:
    Private Sub Form_Load()
    App.HelpFile = App.Path & "\help.chm"
    End Sub
    If my post was helpful please rate it

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    13
    Thanks! That's just what I needed!
    Bryan

  6. #6
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Originally posted by boroarke
    I would prefer it not to open in notepad. Id just like it to launch the help file I compiled. Any other ideas?

    Bryan
    You can still use ShellExecute to open it.

    Code:
    ShellExecute 0&, "open", "file.chm", vbNullString, vbNullString, vbNormalFocus

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    13
    Please excuss my lack of skill, I am brand new. How would I initiate ShellExecute 0&, "open", "file.chm", vbNullString, vbNullString, vbNormalFocus from the click command of my command button? Could someone explain where I place that code and how I get my cmdHelp button to open it?
    Thanks a lot!!
    Bryan

  8. #8
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Place the code I gave you in a button, that's it.

    Make sure you have the following line in the "General" (top) part of your Form.
    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

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    13
    okay, once I have that in the top part of the form, how do I call it using my cmdHelp button?
    Thanks,
    Bryan

  10. #10
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Put the code I gave you in your cmdHelp_Click() event
    Code:
    ShellExecute 0&, "open", "file.chm", vbNullString, vbNullString, vbNormalFocus
    Replace file.chm with the full path of your chm file

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