This project has moved and is read-only. For the latest updates, please go here.

How can I get the TopicIDs from a CHM file?

Topics: Developer Forum, User Forum
May 27, 2013 at 5:46 PM
I am generating a CHM file with Sandcastle Help File Builder, based on a csproj file. What I'm ultimately trying to do, is to find the TopicID of each topic in the CHM file, and use them with Excel-Dna like so:

[ExcelFunction(Category = "MyCategory", Name = "MyUDF", HelpTopic="MyHelp.chm!102")]
Even though I know all the URLs for the articles in the CHM file -- I can see the contents with 7zip and HTML Help Workshop (HHW) -- I don't know how to use Sandcastle or HHW to map the topics to certain ids or to find out the ids of the topics I already have.

Any thoughts?


May 28, 2013 at 12:52 AM
The Microsoft.Help.Id metadata attribute is added to each HTML file and contains a unique ID. For MAML topics it is the topic GUID. For API members, it's the member ID though I haven't checked to see if it always matches the one in the XML comments file. If opening the Help 1 file from code, the help navigator topic would be the filename (html/[GUID].htm) and the GUID is the filename GUID for both MAML and API members. I'm not sure what Excel would require.

May 28, 2013 at 9:33 AM
Thanks for your reply Eric.

I have tried to use both the GIUD and member id without success. What I want to ask is can you map certain GUID/IDs to an alias, eg. 102,103, etc, so that I can use that from within C# with Excel-Dna?

Hope you can help with this.

Thanks again,
May 28, 2013 at 5:12 PM
Hi Eric,

I went ahead and created a CHM file with Doxygen, and manually added the [MAP] and [ALIAS] fields in the HPP file in HTML Help Workshop. I've mapped a specific html to the number 1000, so now when I use "MyHelp.chm!1000", it actually opens the right html inside the chm file.
Hence I think it's a feature with Sandcastle not doing the mapping and the aliasing for use with Excel-Dna. I don't want to do this roundabout way, as I was planning on adding this as a build event on the TFS we use.
Do you think there's a way to do this mapping and aliasing automatically as option in the Help File tab options?

I've tried to do this:


But none of them seem to be able to point into the CHM file.

Any thoughts?
May 28, 2013 at 8:06 PM
Sandcastle and SHFB do not generate any MAP or ALIAS entries in the help 1 project file. Given the large number of topics that could potentially be generated, it's probably not a good idea to just generate entries for each topic. It's probably something better left to a plug-in where you can define the specific topics that you want to link to along with the corresponding alias number. That info could then be inserted into the help 1 project file at build time.

May 29, 2013 at 12:06 PM
Can you please provide a high level item list of what needs to be created in order to construct pre-defined MAP/ALIAS pairs, and include them in the Help 1 project file?
I'm looking at this page and I can sort of see what kind of assembly I'll need to code, but I can't see how to structure the MAP/ALIAS entries. I'm thinking I'll create a configuration where you can map a constant number to an existing html file in the CHM.

I would be really grateful for any input on this matter.

Thanks Eric.

May 29, 2013 at 3:58 PM
You'd need to build the help file to get the topic filenames I guess. That's about all I can tell you. Once you've got them, you can enter the names along with a corresponding number that will get used by the plug-in to create the map and alias information that gets added to the help 1 project file. I've never used the map and alias stuff so you're on your own there.