Attribute VB_Name = "MHelp" ' ' Developed by: SolutionsXPress Copyright © 2004-2008 GESansom. All rights reserved. ' ' ProjectName: App_Name Copyright © 2004-2008 GESansom. All rights reserved. ' App_Title_or_Description ' ' ************************************************************************ ' This application not to be sold without written consent from the author. ' ************************************************************************ ' ' Created: 10/22/2004 ' ' Author: Garry Sansom, www.solutionsxpress.com ' ' Description: This module handles Help and User Guide code. ' 'Method1' uses pre-defined application constants (Defined in MOpenClose) as follows: ' gszAPP_NAME The application name. (EXE or XLA) ' gszAPP_HELP_FILE The filename of the help file associated with the application. ' This method assumes using a single CHM file. ' ' 'Method2' accepts a filename argument, and so could be used for multiple CHM files, ' each belonging to a specific subject or feature add-on. ' ' Syntax is provided for use with VB and VBA; ' Assumes CHMs are store in the same folder as the app. ' ' Date Developer Action ' ------------------------------------- ' 01/17/2005 Garry Sansom Created ' Option Explicit Option Private Module Private Const mszModule As String = "MHelp" 'This is required if using 'Method1' Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" (ByVal hwndCaller As Long, ByVal pszFile As String, ByVal uCommand As Long, ByVal dwData As Long) As Long 'These are required if using 'Method2' Public Declare Function GetDesktopWindow Lib "user32" () As Long Public Declare Function HtmlHelpA Lib "hhctrl.ocx" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '[Method1] Sub GetHelpTopic(ByVal lTopic As Long) ' Displays the specified topic in the Help and User Guide ' Can be called from anywhere, making it suitable for 'in context' use. ' ' Arguments: lTopic [in] The mapped numeric topic ID to be displayed when the help file opens. ' Const sSource As String = "GetHelpTopic()" Const HH_HELP_CONTEXT = &HF '//display mapped numeric ID Dim Result 'Toggle the comment state, 'and edit the path info appropriately. Result = HtmlHelp(0, ThisWorkbook.Path & "\" & gszAPP_HELP_FILE, &HF, lTopic) 'VBA ' Result = HtmlHelp(0, App.Path & "\" & gszAPP_HELP_FILE, &HF, ByVal lTopic) 'VB6 If Result = 0 Then MsgBox "Cannot display " & gszAPP_NAME & " Help - Topic " & lTopic, vbCritical, gszAPP_NAME End Sub '//GetHelpTopic() ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '[Method2] 'Provided by Excel MVP Rob Bovey Public Sub DisplayHTMLHelpTopic(ByRef szFullName As String, ByVal lTopicID As Long) ''''''''''''''''''''''''''''''''''''''' '' Comments: Displays the specified topic from the specified help file. '' '' Arguments: szFullName [in] The full path and file name to the HTML help '' file to display. '' lTopicID [in] The mapped numeric topic ID to be displayed '' once the help file has been opened. '' '' Date Developer Action '' -------------------------------------------------------------------------- '' 09/18/04 Rob Bovey Created '' Const HH_HELP_CONTEXT = &HF '' display mapped numeric ID Dim lHwnd As Long lHwnd = GetDesktopWindow() HtmlHelpA lHwnd, szFullName, HH_HELP_CONTEXT, lTopicID End Sub '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Using Method1 or Method2 from any control's OnAction or Click event Sub ShowAPPHelp() ' Shows the Help and User Guide by passing the default topic ID to be displayed when the help file is opened. ' Fired from menuitem. ' Replace 'APP' with your own text as desired. Const sSource As String = "ShowAPPHelp()" 'Display Help with the default topic 1 'Method1 'Toggle the comment state, ' GetHelpTopic 1 'Mthod2 'Toggle the comment state, 'and edit the path info appropriately. DisplayHTMLHelpTopic ThisWorkbook.Path & "\" & gszAPP_HELP_FILE, 1 'VBA ' DisplayHTMLHelpTopic App.Path & "\" & gszAPP_HELP_FILE, 1 'VB6 End Sub '//ShowAPPHelp()