How to Load the Windows Help File Using WordBasicLast reviewed: February 5, 1998Article ID: Q126087 |
The information in this article applies to:
SUMMARYThis article describes how to use WordBasic to load your own Windows Help file. Below is a sample WordBasic macro that calls the WinHelp() Windows API function. WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Word Version 6.0 for WindowsREM The declaration for WinHelp is as follows: Declare Sub WinHelp Lib "User" (hWnd As Integer, lpHelpFile$ As String,wCommand As Integer, dwData As Long) REM The GetFocus SDK function to obtain the handle of Word which is the REM hWnd parameter to WinHelp Declare Function GetFocus Lib "User"() As Integer Sub Main hWnd = GetFocus WinHelp (hWnd, "c:\winword\winword.hlp", 3, 0) End Sub Word Version 6.0 for Windows NT, Word 7.0 for Windows 95REM The declaration for WinHelp32 is as follows: Declare Function WinHelp Lib "user32" Alias "WinHelpA"(hwnd As Long,lpHelpFile$ As String, wCommand As Long, dwData As String) As Long REM The GetFocus SDK function to obtain the handle of Word which is the REM hWnd parameter to WinHelp Declare Function GetFocus Lib "user32" Alias "GetFocus"() As Long Sub MainhWnd = GetFocus WinHelp(hWnd, "c:\msoffice\winword\wrdbasic.hlp", 261, "") End Sub MORE INFORMATIONThe hWnd parameter is the window handle to Word, the active application. The lpHelpFile$ parameter is the path and name of the Help file. The wCommand parameter to the WinHelp function is set to the number 3 so that Help will display the contents or first page of the Help file. See below for an explanation of the dwData parameter. You can also go to a particular section of a Help file depending upon a keyword by doing the following:
Word Version 6.0 for Windows
Declare Sub WinHelp Lib "User" (hWnd As Integer, helpfilename$ As String,wCommand As Integer, dwData As String) Declare Function GetFocus Lib "User"() As Integer Sub Main helpfilename$ = "c:\winword\winword.hlp" hwnd = GetFocus text$ = "normal view" WinHelp(hwnd, helpfilename$, 257, text$) End Sub Word 6.0 for Windows NT, Word 7.0 for Windows 95
Declare Function WinHelp Lib "user32" Alias "WinHelpA"(hwnd As Long,helpfilename$ As String, wCommand As Long, dwData As String) As Long Declare Function GetFocus Lib "user32" Alias "GetFocus"() As Long Sub Main helpfilename$ ="c:\msoffice\winword\wrdbasic.hlp" hWnd = GetFocus text$ = "msgbox$" WinHelp(hWnd, helpfilename$, 257, text$) End SubNotice that the dwData parameter can be either Long or a String depending on how you are calling the WinHelp function. NOTE: Always call dwData as String from 32 bit versions of Word.
wCommand parameter Defined in Windows.H Decimal Equivalent ================== ==================== ================== HELP_CONTEXT 0x0001 1 HELP_QUIT 0x0002 2 HELP_INDEX 0x0003 3 HELP_CONTENTS 0x0003 3 HELP_HELPONHELP 0x0004 4 HELP_SETINDEX 0x0005 5 HELP_SETCONTENTS 0x0005 5 HELP_CONTEXTPOPUP 0x0008 8 HELP_FORCEFILE 0x0009 9 HELP_KEY 0x0101 257 HELP_COMMAND 0x0102 258 HELP_PARTIALKEY 0x0105 261 REFERENCESMicrosoft Word for Windows 6.0 On-Line Help, WordBasic, Declare Example Microsoft Windows SDK "Programming Tools," Chapter 3, "Creating Help Files" Microsoft Windows SDK "Programmer's Reference, Volume 2: Functions," pages 985-988
|
KBCategory: kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |