Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2005
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help Files (XP (2002))

    I am creating a help file for an Access database. All is well for the objects (forms, reports etc) using the Help file name and Context ID. However, I would like to be able to run this help file from the Menu. I have tried creating a new menu with new menu items etc but haven't really got a clue. I have tried using a macro with a sendkey of F1 with this menu item after creating a Custom command but this is not the way.

    Does anyone know of a way to make a custom help file the exclusive and only help file for a database (ie turn off Access Help) and how to run this custom help file from a custom control from a personalised menu bar?

    Thank you

    Rob

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Help Files (XP (2002))

    Welcome to Woody's Lounge.

    The Developer Solutions sample database from Microsoft (see Sample Applications Download) contains the following code:

    Private Declare Function WinHelp Lib "user32" Alias "WinHelpA" _
    (ByVal hWnd As Long, ByVal lpHelpFile As String, _
    ByVal wCommand As Long, ByVal dwData As Long) As Long

    Function ShowHelpAPI() As Boolean
    ' This procedure is used by the Show Me button on various Developer
    ' Solutions toolbars. It uses the WinHelp API function so that the
    ' Show Me Help button will provide context-sensitive Help regardless
    ' of the current state of the object. Make sure that the Help file is
    ' in the same directory as the Developer Solutions database.

    Dim lnghWnd As Long, strHelpFile As String, lngContext As Long
    Dim lngRetVal As Long, obj As Object

    On Error Resume Next
    Const conHelpContext = &H1
    Set obj = Screen.ActiveForm

    If Err = 2475 Then
    ' Active object is not a form.
    ' Reset Err and test for Report object.
    Err = 0
    Set obj = Screen.ActiveReport
    If Err = 2476 Then
    ' Current object is not a form or a report.
    MsgBox "Select a form or report before you ask for help."
    ShowHelpAPI = False
    Exit Function
    End If
    End If

    With obj
    ' Get the current object's hWnd, HelpFile, and HelpContextID properties.
    lnghWnd = .hWnd
    strHelpFile = Left(CurrentProject.FullName, _
    InStrRev(CurrentProject.FullName, "")) & .HelpFile
    lngContext = .HelpContextId
    End With

    lngRetVal = WinHelp(lnghWnd, strHelpFile, conHelpContext, lngContext)
    ShowHelpAPI = True
    End Function

    You can adapt this function to your own needs.

    The database has a custom toolbar button whose On Action property is set to =ShowHelpAPI().

    You can make the F1 key run the ShowHelpAPI function:
    - Create a macro named AutoKeys (this name is mandatory)
    - Display the macro names column
    - Enter {F1} in the macro name column.
    - Select RunCode in the action column
    - Enter ShowHelpAPI() in the function name box.

  3. #3
    New Lounger
    Join Date
    Feb 2005
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help Files (XP (2002))

    Hans,

    Thanks a heap. Absolutely spot on! Works like a charm.

    Rob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •