De: Objet: Re: Changing the assigned help file in VBA projects Date : jeudi 9 septembre 1999 12:42 Hi Axel, On Thu, 02 Sep 1999 16:05:08 +0200, Axel Mayer wrote: >Hello, > >I have a VBA project in which the user can select different languages for the >dialogs and menues. The help for this project is described in different help >files (*.hpl) for each language. > >How can I manage to change the assigned help file. > >I can assing o n e help file in the project properties. How can I change this >assignment in VBA? > >Visual Basic offers the property 'App.Helpfile'. I have not found such a >property in VBA. > I don't know anyway of changing the name of the help file in the project properties, but I would like the offer the following as a possible alternative. I presume that you will know the location of the various help files and so suggest that you use the API to invoke the help file from your template project. You can declare a module level variable to store the name of the appropriate help file, and change the contents of this variable whenever the user changes languages. Whenever the user invokes your template's help file, you would pass this variable to the Winhelp function. Some sample code follows: 'Note. You don't need all of these constants. I just included them for the sake of completeness. Public Const HELP_CONTEXT = &H1 'Display topic in ultopic Public Const HELP_QUIT = &H2 'Terminate help Public Const HELP_INDEX = &H3 'Display index Public Const HELP_contentS = &H3& 'Display contents topic Public Const HELP_HELPONHELP = &H4 'Display help on using help Public Const HELP_SETINDEX = &H5 'set current Index for multi 'index help Public Const HELP_SETcontentS = &H5& 'set contents topic Public Const HELP_CONTEXTPOPUP = &H8& 'Popup window for context ID Public Const HELP_FORCEFILE = &H9& 'force specific help file Public Const HELP_KEY = &H101 'Display topic for keyword Public Const HELP_COMMAND = &H102& 'execute winhelp macro Public Const HELP_PARTIALKEY = &H105& 'search Public Const HELP_MULTIKEY = &H201& 'multi-key table Public Const HELP_SETWINPOS = &H203& Public 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 Public declare function findWindowEx Lib "user32" Alias "findWindowExA" _ (ByVal hWnd1 As long, _ ByVal hWnd2 As long, _ ByVal lpClassname As String, _ ByVal lpWindowname As String) As long ' Declare this variable at module level. Private m_hHelpWindow As long 'Call this routine and supply the name of the help file for the chosen language. Public Sub showHelp(ByVal AppHelpFile As String) 'we need to "anchor" the help window to another window. Word's main window does nicely. The findWindowEx function returns this windows handle, which we then store in our variable m_hHelpWindow for later use when we quit the help file. m_hHelpWindow = WinHelp(findWindowEx(0&, 0&, "OpusApp", ""), AppHelpFile, HELP_contentS, 0&) end Sub Public Sub QuitHelp() 'Its "bad manners" to quit an application and leave its help file open so you'll need to call this routine from an appropriate location. WinHelp m_hHelpWindow, "", HELP_QUIT, 0& end Sub Hope this helps, Mark.