• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Pressing F1 tries to open .hlp instead of .chm

harleygnuya

New Member
Windows 10 Pro x 64, Excel from Office 365 version 1705 (Build 8201.2200)

I have written some macros and have some userforms. I've set HelpContextIDs for the controls and specified a .chm as my project's help file.

Action: Activate a control in the userform, then press the F1 key.

Expected behavior: My help (.chm) file should open to the correct page corresponding to the control.

Actual behavior: My browser opens up and displays the following page: https://support.microsoft.com/en-us...dows-based-programs-feature-not-included-or-h

which is a standard page that is displayed when Excel thinks one is trying to use a .hlp file instead of a .chm file for help.

This occurs whenever I try to access help through Excel's help system, meaning when I count on Excel to invoke help itself. That includes not only the way I tried above, but also setting the userform's WhatsThisButton and WhatsThisHelp properties to True. Again, instead bringing up my help file, it goes off to that web page.

I am able to invoke my help file by putting a button for that purpose on the control and in its Click event handler calling Application.Help. This works just fine, so I know my help file is good.

I've even tried setting Application.OnKey for the F1 key to call a Sub that makes the Application.Help call, but Excel captures the F1 press event before I can trap it, and, again, Excel sends me off to that web page. I then tried setting the OnKey for Shift+F1, but Excel captures even that and off it goes. (Or else my OnKey call isn't taking.)

Any suggestions or help would be appreciated.

Thanks
 
Maybe you have to register the CHM for that to work? This has a link to a utility to do that. If that is the case, that would not be good for wide use. It has examples for how to use chm file for other tasks but not a Userform. http://www.help-info.de/en/Visual_Basic_Applications/vba_using_example.htm

The link provides a chm file and some example HelpContextID's so it can be used to test some things.

I don't see an Application.HelpFile. You can try MSForms.HelpFile but it is a very long shot I think.

This link also has some API methods that might help. https://www.excelguru.ca/content.php?166-Using-Help-in-Your-Applications

I hope this "help"s...
 
Thanks, Kenneth. I finally got it working, but I don't quite know how or why. It was one of those things where I tried so many things I don't know what combination made it work. o_O

I think it was related to the help system having trouble finding my .chm file - at least it acted that way. It appears as if the Microsoft help system tries to find you help on its own in certain circumstances if it can't find your help file. It responded to this situation in several different ways and was not consistent (at least not that I could tell) in its reaction, so it made it extremely difficult to chase this one down.

In the end, though, it's working now, and quite well.
 
Hmm, response from phone did not show from this morning. Good deal that it worked for you.

I was going to mention trying to save it to a known SET PATH like c:\windows\system32.

In DOS days, we used Config.sys I think it was to SET PATH's.
 
Actuallly, Kenneth, I did the modern equivalent of this, which was to use the ThisWorkbook.Path property and put the .chm file in the same folder as the workbook. Still had problems with that, though, so the problem was somewhere else.

I'm about to give my age away, but, yes, SET PATH... it's been a lo-o-o-ong time since I've thought of that one. Takes me back...

Thanks!
 
Back
Top