?
Solved

Error: Cannot open Help Pop-up Text file

Posted on 2008-06-19
13
Medium Priority
?
615 Views
Last Modified: 2011-10-19
I am attempting to add context sensitive help to a form. This is my first shot at this technique, so I created a small Access database to test out the concept. I've read many documents/postings from MSDN, this forum and other web sites, and it seems to me that I have assembled the parts correctly, but I am getting an error when I attempt to invoke the Help.
Using HTML Help Workshop (version 4.74.8702.0) I created and compiled file 'HelpDemo.chm'. The Pop-Up text file is named 'HelpDemo.txt'. I have added the pertinent information about HelpDemo.chm and the associated files to the top of the code for the form ('frmHelpDemo'), which can be seen below as a code snippet. All of the objects associated with this effort are in the same folder ("C:\Developer\HelpDemo") which is locally located on my PC.
The error that I am getting is:
"Cannot open the file "HelpDemo.chm:/HelpDemo.txt"
There is no security associated with the mdb or any other of the objects.
I have attached an image of the open form and the error message. I have also attached a zip file of those files in folder "C:\Developer\HelpDemo" that are allowed for upload. Unfortunately HelpDemo.chm isn't one of them. I also changed the extensions of 'alias.h' and 'map.h' to 'txt' to enable their upload.
Any help in resolving this error would be greatly appreciated.
Thanks,
Todd
Option Explicit
   Option Compare Database
   Private strModule As String
 
'---------------------------------------------------
'   HelpDemo.chm Information:                      '
'---------------------------------------------------
'   C:\Developer\Help Problem Demo\HelpDemo.chm    '
'                                                  '
'   Compiled file version 3                        '
'   Compiled on June 19, 2008, at 4:57 PM          '
'   Compiled with HHA Version 4.74.8702            '
'   Default HTML file: txtFirst.htm                '
'                                                  '
'   $FIftiMain                   0 bytes           '
'   $OBJINST                     2,751 bytes       '
'   Folder: $WWAssociativeLinks                    '
'        Property                4 bytes           '
'   Folder: $WWKeywordLinks                        '
'        Property                4 bytes           '
'   HelpDemo.txt                 105 bytes         '
'   txtFirst.htm                 236 bytes         '
'   txtSecond.htm                238 bytes         '
'   2 folders, 7 files, 3,338 bytes                '
'---------------------------------------------------
 
'---------------------------------------------------
'   HelpDemo.txt file contents:                    '
'---------------------------------------------------
'   .topic 1                                       '
'   This is the text file Help for txtFirst        '
'                                                  '
'   .topic 2                                       '
'   This is the text file Help for txtSecond       '
'---------------------------------------------------
 
'---------------------------------------------------
'   Alias.h filecontents                           '
'---------------------------------------------------
'   txtFirstHELP = txtFirst.htm                    '
'   txtSecondHELP = txtSecond.htm                  '
'---------------------------------------------------
 
'---------------------------------------------------
'   Map.h file contents:                           '
'---------------------------------------------------
'   #define txtFirstHELP 1                         '
'   #define txtISecondHELP 2                       '
'---------------------------------------------------
 
 
   ' Declarations for Help File
 
   Private Const HH_DISPLAY_TOPIC As Long = &H0
   Private Const HH_SET_WIN_TYPE As Long = &H4
   Private Const HH_GET_WIN_TYPE As Long = &H5
   Private Const HH_GET_WIN_HANDLE As Long = &H6
   Private Const HH_DISPLAY_TEXT_POPUP As Long = &HE
   Private Const HH_HELP_CONTEXT As Long = &HF
   Private Const HH_TP_HELP_CONTEXTMENU As Long = &H10
   Private Const HH_TP_HELP_WM_HELP As Long = &H11
   
   Private Declare Function HtmlHelpByRefArg Lib "hhctrl.ocx" Alias "HtmlHelpA" _
               (ByVal hwndCaller As Long, ByVal pszFile As String, _
               ByVal uCommand As Long, ByRef dwData As Any) As Long
   
   Private Declare Function GetDlgCtrlID Lib "user32" (ByVal hWnd As Long) As Long
   
   Private Type HH_IDPAIR
      dwControlId As Long
      dwTopicId As Long
   End Type
   
   Private Const g_sHTMLHelpFile As String = "HelpDemo.chm:/HelpDemo.txt"
 
   ' This array must contain the number of controls that have
   ' context-sensitive Help, plus one more for a zero-terminating pair.
   Private ids(2) As HH_IDPAIR
 
Private Sub Form_Load()
   strModule = Me.Name
   LoadHelpArray
End Sub
 
Private Sub txtFirst_KeyUp(KeyCode As Integer, Shift As Integer)
      Dim strProcedure As String
      Dim lngReturn As Long
      Dim strMsg As String
 
10    On Error GoTo ErrorHandler
20    strProcedure = "txtFirst_KeyUp"
 
30    If KeyCode = vbKeyF2 Then
40       lngReturn = HtmlHelpByRefArg(Me.hWnd, g_sHTMLHelpFile, _
               HH_TP_HELP_WM_HELP, ids(0))
50    End If   'If KeyCode = vbKeyF2
 
ExitSub:
60    Exit Sub
 
ErrorHandler:
70    DoCmd.Hourglass False
80    strMsg = "Module: " & strModule & vbCrLf & _
               "Procedure: " & strProcedure & vbCrLf & _
               "Error: " & Err.Description & _
               " (" & Err.Number & ")" & vbCrLf & _
               "Line Number: " & Erl
90    Debug.Print strMsg
100   MsgBox strMsg
110   Resume ExitSub
End Sub
 
Private Sub txtSecond_KeyUp(KeyCode As Integer, Shift As Integer)
      Dim strProcedure As String
      Dim lngReturn As Long
      Dim strMsg As String
 
10    On Error GoTo ErrorHandler
20    strProcedure = "txtSecond_KeyUp"
 
30    If KeyCode = vbKeyF2 Then
40       lngReturn = HtmlHelpByRefArg(Me.hWnd, g_sHTMLHelpFile, _
               HH_TP_HELP_WM_HELP, ids(1))
50    End If   'If KeyCode = vbKeyF2
 
ExitSub:
60    Exit Sub
 
ErrorHandler:
70    DoCmd.Hourglass False
80    strMsg = "Module: " & strModule & vbCrLf & _
               "Procedure: " & strProcedure & vbCrLf & _
               "Error: " & Err.Description & _
               " (" & Err.Number & ")" & vbCrLf & _
               "Line Number: " & Erl
90    Debug.Print strMsg
100   MsgBox strMsg
110   Resume ExitSub
 
End Sub
 
Private Sub LoadHelpArray()
      Dim strProcedure As String
      Dim strMsg As String
 
      ' For each control that has a text popup window,
      ' set the values in the ids array. The first item
      ' should be the control id, which you can obtain
      ' by using the GetDlgCtrlID routine. The second
      ' item should be the topic id that appears in the
      ' topic text file.
      ' NOTE: The last pair in the array must contain zeros (0).
 
10    On Error GoTo ErrorHandler
20    strProcedure = "LoadHelpArray"
 
30    ids(0).dwControlId = GetDlgCtrlID(Me.hWnd)
40    ids(0).dwTopicId = txtFirst.HelpContextId
50    ids(1).dwControlId = GetDlgCtrlID(Me.hWnd)
60    ids(1).dwTopicId = txtSecond.HelpContextId
70    ids(2).dwControlId = 0
80    ids(2).dwTopicId = 0
 
ExitSub:
90    Exit Sub
         
ErrorHandler:
100   DoCmd.Hourglass False
110   strMsg = "Module: " & strModule & vbCrLf & _
         "Procedure: " & strProcedure & vbCrLf & _
         "Error: " & Err.Description & _
         " (" & Err.Number & ")" & vbCrLf & _
         "Line Number: " & Erl
120   Debug.Print strMsg
130   MsgBox strMsg
140   Resume ExitSub
End Sub

Open in new window

HelpDemo-Error.bmp
HelpDemo.zip
0
Comment
Question by:shambalad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 21837322
see if the function code in the link helps:
             http://support.microsoft.com/kb/275117
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 21837432
See #1 below for the most promising of several recommendations by Pete Lees (MVP). If the suggestion below does not help then see other suggestions in post #4 at this link : http://www.pcreview.co.uk/forums/thread-487749.php

1) Use MJ's Help Diagnostics to check that all the help viewer
components are properly installed and registered.

http://helpware.net/downloads/index.htm#MJs

(The only section of the MJ's Help Report that is relevant to your
problem is the one headed "HTML Help Run-time Components".)
0
 
LVL 7

Author Comment

by:shambalad
ID: 21837950
puppydogbuddy -
Thanks for looking into this. The HHContex download on the Helpware site looks like it could be useful too.
http://www.pcreview.co.uk/forums/forum-250.php - Another Access forum - Great!
The setup I am working on is on my PC in the office. I will follow-up on this first thing in the morning on Monday.
I really appreciate your reaching out to help me on this one.
Todd
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 7

Author Comment

by:shambalad
ID: 21847027
Hello -
Just thought I'd post an update on where I'm at with this.
I created a new module (I named it "basHelp") as suggested in the MSDN article 275117 (http://support.microsoft.com/kb/275117). I also created a new Macro named "AutoKeys" that runs help when F2 is pressed.
I commented out the all of code in the Form frmHelpDemo module, since all of the operations associated with showing help are now in module "basHelp". I deleted the pop-up text file HelpDemo.txt, since all of the help will be HTML based.
I created another HTML file named "frmHelpDemo.htm" as the 'form-level' help file. In the MSDN file, I noticed that the Alias and Map files were both using integers instead of strings for the cross-reference key between the two files, so I did the same. The entries in Alias.h also had a semicolon at the end of each line; I added them too. The file contents are as follows:

Alias.h contents:
1 = frmHelpDemo.htm;
2 = txtFirst.htm;
3 = txtSecond.htm;

Map.h contents
#define 1 1
#define 2 2
#define 3 2

I deleted then re-created HelpDemo.chm.

I added another textbox (txtThird) to frmHelpDemo. This control has no Help Context ID associated with it. The Help Context IDs for the form are:
Name                  Type          Help Context ID
frmHelpDemo       Form                   1
txtFirst                 Textbox              2
txtSecond             Textbox             3
txtThird                Textbox             Null

The results of these changes. When the focus is on txtFirst or txtSecond and I press F2, nothing is displayed. The public sub Show_Help returns a value for the Help Window handle; that value is zero. When I press F2 while the focus is on txtThird, the 'Form-level' help (i.e. frmHelpDemo.htm) is displayed. This is correct. I don't know why  txtFirst and txtSecond  aren't working. I'm still trouble-shooting that.
I have attached the updated mdb. I have also copied in the basHelp module as a snippet.
BTW, I ran 'MJ's Diagnostics' and the results indicated that all of the required DLLs, etc. were present.
Todd
Option Explicit
Option Compare Database
Private Const strModule As String = "basHelp"
 
Private Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
        (ByVal hwndCaller As Long, ByVal pszFile As String, _
         ByVal uCommand As Long, ByVal dwData As Long) As Long
 
Private Const HH_DISPLAY_TOPIC = &H0
Private Const HH_SET_WIN_TYPE = &H4
Private Const HH_GET_WIN_TYPE = &H5
Private Const HH_GET_WIN_HANDLE = &H6
Private Const HH_DISPLAY_TEXT_POPUP = &HE
Private Const HH_HELP_CONTEXT = &HF
Private Const HH_TP_HELP_CONTEXTMENU = &H10
Private Const HH_TP_HELP_WM_HELP = &H11
 
Public Sub Show_Help(strHelpFile As String, lngContextID As Long)
    Dim lngHwndHelp As Long
    'A specific topic identified by the variable context-ID is started in
    'response to this button click.
 
    'The return value is the window handle of the created Help window.
    Select Case lngContextID
        Case 0
            lngHwndHelp = HtmlHelp(Application.hWndAccessApp, strHelpFile, _
                       HH_DISPLAY_TOPIC, lngContextID)
        Case Else
            lngHwndHelp = HtmlHelp(Application.hWndAccessApp, strHelpFile, _
                       HH_HELP_CONTEXT, lngContextID)
    End Select
Debug.Print lngHwndHelp
End Sub
 
Public Function HelpEntry()
    Dim frmrHelpFile As String
    Dim frmCurrent As Form
    Dim lngHelpID As Long
    
    'Identify the name of the Help file and a possible context-id.
 
    'Set the frmCurrent variable to the currently active form.
    Set frmCurrent = Screen.ActiveForm
 
    'As a default, specify a generic Help file and context-id. Note that
    'the location of your file may be different.
    frmrHelpFile = "C:\Developer\HelpDemo\HelpDemo.chm"
    lngHelpID = 1001
 
    'Check the Help file property of the form. If a Help file exists,
    'assign the name and context-id to the respective variables.
    If frmCurrent.HelpFile <> "" Then
        frmrHelpFile = frmCurrent.HelpFile
    End If
 
    'If the Help context-id of the control is not null and greater than
    'zero, assign the value to the variable.
    If Not IsNull(Screen.ActiveControl.Properties("HelpcontextId")) Then
        If Screen.ActiveControl.Properties("HelpcontextId") > 0 Then
            lngHelpID = Screen.ActiveControl.Properties("HelpcontextId")
        End If
    End If
 
    'Call the function to start the Help file, passing it the name of the
    'Help file and context-id.
    Show_Help frmrHelpFile, lngHelpID
End Function

Open in new window

HelpDemo.mdb
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 21847633
Todd,
I only have Access 2000, and could not open your demo file. Nonetheless, as best as I can remember,  forms and reports each have two properties, Help File and HelpContextID which are embedded in each and every form and report. Looking at one of my reports, here is the setting I had for those 2 properties:
Help File   XXXXX_Help.HLP   where XXXX is the Name of my App.
Help ContextID         14

Note the use of the .HLP extension rather .CHM

Hope this helps.
0
 
LVL 7

Author Comment

by:shambalad
ID: 21847835
puppydogbuddy -
I'll take a look at the hlp extension. In the HelpEntry function (see the code snippet above), the Help file name is set with a default if there is none associated with the form itself. All of the MS documentation I've seen so far uses the x.chm file for the helpfile name.
I've been doing a little more testing. There is a 'Test HTML Help API' utility option available in the HTML Workshop. When testing context IDs, 1 (mapped to frmHelpDemo.htm) works, but 2 and 3 (mapped to txtFirst.htm and txtSecond respectively) don't. I have a feeling this is a key clue, but I don't know what to do about it. I'll be investigating this more.
Todd
Test-API-Error.bmp
0
 
LVL 7

Author Comment

by:shambalad
ID: 21874757
I'm stuck...
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 21874973
Provide some more details.  In the meantime try putting the help files in the same folder as your mdb  and see if that makes any difference.
0
 
LVL 7

Author Comment

by:shambalad
ID: 21875210
All of the associated objects are in the same folder on my local drive:
"C:\Developer\HelpDemo"
Basically I'm still where I was back on Monday, June 23rd (see prior posts). The HTML Worksheet has this 'Test HTML Help API' utility which indicates that I have an error (it appears it's not finding the htm files mapped to '2' or '3' in the map.h), but I haven't yet found any documentation on what this error is supposed to be indicating to me or how to fix it. The map.h and alias.h files certainly look OK to me, but then I don't know what I don't know...
I am going to be leaving the office shortly to have a 'routine' surgical procedure performed. Since they will be putting me under anaesthesia I will be more useless than usual for the rest of the day. Tomorrow I will drop by my local bookstore (i.e. my technical library) and see if they have any books on HTML Help.
Thanks for hanging in there with me there puppydogbuddy.
Todd
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 21882943
It seems that in some cases displaying html help is due to the implementation of sandbox security updates by ms in Access versions begining in 2002, especially If you've installed security update 896358. That will block HTML Help  files that you've downloaded from the Internet or that you're accessing over a network. You can get more information and workarounds here:

 http://support.microsoft.com/?kbid=896358

Check and see if this could be your problem.
0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 21883038
see this link for help with errors displaying chm files.

         http://www.help-authoring.info/?p=14
 
0
 
LVL 7

Author Comment

by:shambalad
ID: 22058935
Just wanted to add a comment that I haven't really abandoned this question. Although I haven't come up with a solution, I am still spending time (when I can) in trying to figure out how to get help to work with my projects.
Todd
0
 
LVL 7

Accepted Solution

by:
shambalad earned 0 total points
ID: 22062183
Well I have come up with a solution that is going to work for me. Basically, I have decided to use WinHelp instead of HTML Help for now. These are both MS technologies, although WinHelp is the older of the two. Nonetheless, I do get the impression that WinHelp is better suited for Access. My understanding is that WinHelp could be problematic with Vista, but this corporation is not going to move from XP any time soon (imagine converting 70,000+ PCs from XP to Vista!). WinHelp will do for now.
Anyway, I used HelpScribble ($99.00) to create the .hlp file. The implementation in VBA was just about effortless.
Thank you puppydogbuddy for your assistance.
I am going to close out this question.
Todd
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question