Open Custom Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sconard
    New Member
    • Jan 2008
    • 21

    #1

    Open Custom Help

    Two related issues:
    1.
    I would like to place a button on my form to open the helpfile that was set on form load. I cannot find the syntax for opening the helpfile from a button on a form.

    'sets help file on form load
    Private Sub Form_Load()
    Form.Helpfile = CurrentProject. Path & "\helpfile. chm"
    end sub

    2.
    If a user opens the form that has this helpfile set, the microsoft access help will open if the user clicks F1 prior to clicking on any controls of the form. Is there any way around this so that the set helpfile opens if the user clicks F1 prior to clicking on the form?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by sconard
    Two related issues:
    1.
    I would like to place a button on my form to open the helpfile that was set on form load. I cannot find the syntax for opening the helpfile from a button on a form.

    'sets help file on form load
    Private Sub Form_Load()
    Form.Helpfile = CurrentProject. Path & "\helpfile. chm"
    end sub

    2.
    If a user opens the form that has this helpfile set, the microsoft access help will open if the user clicks F1 prior to clicking on any controls of the form. Is there any way around this so that the set helpfile opens if the user clicks F1 prior to clicking on the form?
    You can Open a Help File (*.chm), or any File for that matter, simply based solely on its Extension. Follow these 3 Steps:
    1. Actual code to Open the Help File.
      [CODE=vb]
      Dim blnRetVal As Boolean
      blnRetVal = Execute_Program (CurrentProject .Path & "\Helpfile.chm" , "", "")[/CODE]
    2. Declaration in Standard Code Module.
      [CODE=vb]
      Declare Function ShellExecute Lib "shell32.dl l" _
      Alias "ShellExecu teA" (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[/CODE]
    3. Public Function, with extensive Error Checking code, so that this functionality can be used anywhere in your Application.
      [CODE=vb]
      Public Function Execute_Program (ByVal strFilePath As String, _
      ByVal strParms As String, ByVal strDir As String) _
      As Boolean

      'run program ' <R6>
      Dim hwndProgram As Integer
      hwndProgram = ShellExecute(0, "Open", strFilePath, strParms, strDir, 3) '3 ==> Show Maximized

      'evaluate errors (if any)
      Select Case (hwndProgram)
      Case 0
      MsgBox "Insufficen t system memory or corrupt program file."
      Execute_Program = False
      Exit Function
      Case 2
      MsgBox "File not found."
      Execute_Program = False
      Exit Function
      Case 3
      MsgBox "Invalid path."
      Execute_Program = False
      Exit Function
      Case 5
      MsgBox "Sharing or Protection Error."
      Execute_Program = False
      Exit Function
      Case 6
      MsgBox "Seperate data segments are required for each task."
      Execute_Program = False
      Exit Function
      Case 8
      MsgBox "Insufficie nt memory to run the program."
      Execute_Program = False
      Exit Function
      Case 10
      MsgBox "Incorrect Windows version."
      Execute_Program = False
      Exit Function
      Case 11
      MsgBox "Invalid program file."
      Execute_Program = False
      Exit Function
      Case 12
      MsgBox "Program file requires a different operating system."
      Execute_Program = False
      Exit Function
      Case 13
      MsgBox "Program requires MS-DOS 4.0."
      Execute_Program = False
      Exit Function
      Case 14
      MsgBox "Unknown program file type."
      Execute_Program = False
      Exit Function
      Case 15
      MsgBox "Windows program does not support protected memory mode."
      Execute_Program = False
      Exit Function
      Case 16
      MsgBox "Invalid use of data segments when loading a second instance of a program."
      Execute_Program = False
      Exit Function
      Case 19
      MsgBox "Attempt to run a compressed program file."
      Execute_Program = False
      Exit Function
      Case 20
      MsgBox "Invalid dynamic link library."
      Execute_Program = False
      Exit Function
      Case 21
      MsgBox "Program requires Windows 32-bit extensions."
      Execute_Program = False
      Exit Function
      Case Else
      End Select
      'All is well if we get to this point
      Execute_Program = True
      End Function[/CODE]

    Comment

    • sconard
      New Member
      • Jan 2008
      • 21

      #3
      Thanks but

      Thanks. Very nice bit of code and useful for many things.
      What would be preferable is to open the help page associated with the form with some call. This allows the help to open within access and not force user to close separate window. In addition it uses the default helpfile set for the form which is already defined.

      I also still do not know how to have the set helpFile for the form open with an F1 depress prior to clicking on a control on the form.
      Last edited by NeoPa; Feb 28 '08, 08:06 PM. Reason: Quote unnecessary & complicates thread

      Comment

      Working...