Reputation: 49659
Is there a way to link to a chm file, and therein to a certain topic, from a Microsoft Word docx document? Something in the lines of:
"For more information about this Property see [link ref="./SomeDirectory/somedocument.chm!Sometopic.Somesubtopic" text="MyClass.MyProperty"]
Upvotes: 4
Views: 3262
Reputation: 25429
You should be able to do it by setting the hyperlink to the file and use the "#" header anchor (I'm not sure what it is called...) but here is an example:
C:\Helpfiles\Help.chm#Topic
Upvotes: 0
Reputation: 176279
I don't think that simply a file link to the .chm file will do the job.
For me, the following link format works (note that the .chm file must be in a trusted location, network shares will not work per default):
mk:@MSITStore:C:\SomeDirectory\help.chm::/helppage.htm
EDIT
For relative paths it seems the following pattern must be used:
ms-its:.\help.chm::/html/main.htm
This link will be opened in IE (right-click in the HTML help viewer to see the location of this link under properties).
Another option would be to insert a MACROBUTTON and have a macro opening the HTML help viewer. This would be the VBA code:
Declare Function HtmlHelp Lib "HHCtrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
dwData As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function GetWindowHandle() As Long
'obtain Word's hwnd
'NOTE: there is a possibility of getting the wrong hwnd. If two word windows
'are open with the same caption, this *could* happen. In order to prevent this,
'you can either change the caption to something strange before trying to find it,
'or you can compare processId's with GetCurrentProcessId and GetWindowThreadProcessId
'You can always search the top level windows yourself.
GetWindowHandle = FindWindow(Word8ClassName, ActiveDocument.Windows(1) & " - " & ActiveDocument.Application.Caption)
End Function
Public Function ShowHelp(strPage As String)
On Error Resume Next
HtmlHelp GetWindowHandle, "fullpathtohelpfile.chm", HH_DISPLAY_TOPIC, ByVal strPage
End Function
Upvotes: 2
Reputation: 20299
In order to find the address of a page in a chm file, you need to richt-click the page (the page itself, not the link in the contents tree) and select 'Properties'. Under 'Address (URL)', you find what you are looking for, something like
mk:@MSITStore:D:\Tools\Foo\Bar.chm::/help/base/index.html
And the good thing: You can select the text in the property sheet with your mouse and copy it ;-)
As for how you have to insert the URL into word in order for this to work, I have no idea, but a short trial and error should get you there.
Upvotes: 0