Solved

Context Sensitive Help in VBA7

Posted on 2014-01-14
22
779 Views
Last Modified: 2014-01-22
Hi All,

I'm trying to get context sensitive help working with MS Word User Forms...  I already have a CHM help file, I can get that working from VBA, but what I want is the user to be able to press F1 and get context sensitive help.

On the user form I have set "whatsthishelp" & "whatsthisbutton" both to true.  On my test button I have entered a help contextID as an integer.

When I set the focus to the button and press F1 I get a message saying:
Why can't I get Help from this program?
The Help for this program was created in Windows Help format, which depends on a feature that isn't included in this version of Windows. However, you can download a program that will allow you to view Help created in the Windows Help format.
For more information, go to the Microsoft Help and Support website.

When I visit the MS support website using the link provided

My help file is CHM, it seems that the context sensitive help is looking for a HLP file instead.  It seems that I need to install a legacy tool... surely I am missing something.

In the VBA project properties I have specified a help file name.  It lets me choose my CHM file.

What am I missing?

I found some information about using context sensitive help here: Help Scribble seems that I am stuck with the .HLP format which is no longer supported by MicroSoft?!

Please tell me what I'm missing or confirm that what I am attempting is no longer possible.

Thanks!
0
Comment
Question by:DrTribos
  • 12
  • 10
22 Comments
 
LVL 14

Author Comment

by:DrTribos
ID: 39781318
And then there is this MS Help Topic on Help... which suggests to me that what I want to do is possible... it relates to user forms in office 2013 BUT says:
The HelpContextID property associates a specific topic in a custom Microsoft Windows Help file with a specific control.


What exactly is a "custom Microsoft Windows Help file", is it a .HLP file?
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39781349
OK update... so now I have the situatoin where my userform is open and when I press F1 my help file appears.

However, for this to happen it seems that I must have HelpContextID set to 0 for the control that has focus.

If I change the HelpContextID it stops working - ideas?
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39781379
OK another update - I can get the context sensitive help working for the userform but not for individual controls on the userform...

On the userform:

1.

enter an integer for the HelpContextID corresponding to the chm file

2.

set whatsthisbutton to True

3.

set whatsthishelp to True

4.

on each control in the userform set the HelpContextID to 0
If anyone can tell me how to get this working for individual controls that would be great.  At this stage I don't think it is possible without either a lot of effort or a workaround.

Thanks,
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39782052
Hi,

Are you clicking on the "?" button and then the controls?

Each control should have its HelpContextID Long Number

Regards
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39782061
No, I was just pressing F1...

If I have a number next to the HelpContextID for a control on the form then my CHM won't load, I get a message in my web browser instead.  If I keep it 0 the CHM loads.

When I have a userform open I am unable to click the "?" button - I'm assuming you are referring to the blue circle with the '?' in it which is located on the ribbon in the right hand corner.

I know what a long data type is, my help IDs are defined as integers...
Public Const IDH_ABOUT    As Integer = 10
Public Const IDH_TOPIC20  As Integer = 20
Public Const IDH_TOPIC30  As Integer = 30
Public Const IDH_TOPIC40  As Integer = 40
.....

Open in new window

Could that be part of the problem?  :-/
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39782127
Hi,

No I mean this buttonHelpbuttonRegards
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39782166
Wow... you know I've never really noticed that button before.  Either way it does not seem to work for me.  I get the same error as when I give focus (by right clicking a button) and then pressing F1.
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39793567
Update: well this took a back seat when I tried using Office 2013 and a few things broke!  Right now I have context sensitive help working for the userform as a whole, just not for individual items on the userform.  I'm using .CHM file and don't want to go to another type of help file.  

In short I have made no progress on this.  It might be the case that I'm stuck with this???
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39793576
Hi,

I will try some things later on today

Regards
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39794893
Hi,

in the reference it says
pressing SHIFT+F1 and then clicking the control, or by clicking What's This? on the Help menu
not F1

http://msdn.microsoft.com/en-us/library/office/aa164757(v=office.10).aspx

Have you tried Shift-F1?

Regards
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39796184
hi,

You could use a workaround like this

Private Sub CommandButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyF1 Then  ' 112
    Application.Help "YourHelpfile", "ContextId"
End If
End Sub

Open in new window

Regards
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Author Comment

by:DrTribos
ID: 39796253
Hi Rgonzo - thank you I will have a look...

My main problem is that the user will press F1 expecting help...  I think your workaround would be good if I can get it to fire when the control gets focus (i.e. from a right mouse click).

For now, however, I need to find some dinner!

Cheers,
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39796313
Hi,

That's the case but you have to have the code for each control.

Regards
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39796330
Sorry for the question. What would the user press first F1 or click the button.  My guess is clickthe bbutton causes the vba to wait for a key press?
Away from the computer at the moment so can't check just yet.
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39796339
Hi,

The button has to have the focus first with a tab or with a right-click then if you type F1 the event code of the control will fire the corresponding Help (determenied by the code).

Regards
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39796346
Great - look forward to testing :-)
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39799209
Hi Rgonzo - well you made quite a difference, the help file will open now.  But so will the other help file saying there is no help (and it opens over the top of my help file).  

I just noticed that I did not update my labels to say that I am using Office 2013, not sure if this is the point of difference that leads to this specific behavior.

Do you know of a way to suppress the other help? - I don't think it is possible.

Cheers (and thank you)
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39799212
HI,

Now that you are using the workaround maybe by unabling the contextual help

Regards
0
 
LVL 14

Author Comment

by:DrTribos
ID: 39799216
Sorry - I don't understand the comment.  Do you mean disabling the default help in MS Word?

I did not know that was possible... will look
0
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 500 total points
ID: 39799244
Hi

Higher you said
On the userform:
enter an integer for the HelpContextID corresponding to the chm file
set whatsthisbutton to True
set whatsthishelp to True
on each control in the userform set the HelpContextID to 0

I was speaking of disabling that

Regards
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39799256
Hi,

Maybe

Private Sub CommandButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyF1 Then  ' 112
    KeyCode = 0 ' So it wont try to use another time as F1
    Application.Help "YourHelpfile", "ContextId"
End If
End Sub

Open in new window

Regards
0
 
LVL 14

Author Closing Comment

by:DrTribos
ID: 39799282
Hi Rgonzo - I think you're about to out rank me... A for Excellent thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show you how to use shortcut menus in the Access run-time environment.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now