tags:

views:

497

answers:

3

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"]

A: 

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

I'm not sure if that will work, but I think it will...

Regards,
Frank

Frank V
But how do I get the name of the topic? They are nested in the chm. C:\Helpfiles\Help.chm#MyClassName does not work for once.
bitbonk
I don't think I'm following your question... I don't understand...
Frank V
In the chm file on the right side I have a tree (note: not a list) of topics. Now just providing the name of the tree node (e.g. C:\Helpfiles\Help.chm#MySubSubTopic) does not yield the expected results. However #MyMainTopic/MySubTopic/MySubSubTopic doesn'T work either. I need to find the topicname.
bitbonk
(on the left side, not on the right, of course)
bitbonk
+1  A: 

Hi,

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

(see http://www.helpware.net/htmlhelp/linktochm.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

Hope this is of any help.

Regards, divo

0xA3
For security reasons im not allowed to use macros. The mk:@MSITStore:C:\SomeDirectory\help.chm::/helppage.htm links work fine though. There is only one problem: I cannot specifiy an absolute path, but rather have to use a relative one (the chm and the docx always reside in the same folder).
bitbonk
See my edit for relative paths.
0xA3
A: 

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.

Treb
In this case the chm file must be in a static location that never changtes because the absoulte path is specified. It would be be much better if there would be a way of specifying a relative path. In my scenarion a folder is delivered to the customer containing both .chm and .docx
bitbonk
All right, just replace the absolute path with a relative one: mk:@MSITStore:..\chm\Bar.chm::/help/base/index.html. I suspect that you do not need the 'mk:@MSITStore:' part anyway.
Treb