Help Files

A

Apollyon

I am using a 3rd party software RoboHelp to write a help file for an
Excel VBA rpoject. I need help on understanding how the HelpContextID
property gets mapped into the help file. I have tried various
combinations of using the MapID module on RoboHelp but whe I try to get
context help on a particular userform control the help file does not
recognize the Map ID and associate it with the HelpContextID property
for the VBA project.
 
R

RB Smissaert

I had the same trouble and found the easiest way to solve this was have a
conversion table that converts the HelpContextID's to the bookmarks and then
load the topic from the bookmarks.
So, your conversion table (I have this in a simple text file) will look like
this:

1031,Colour_Options.htm
1032,Colour_Options.htm#GeneralInfoColourOptions
1033,Colour_Options.htm#LoadColourScheme
1034,Colour_Options.htm#ReturnDetaultColours
1035,Colour_Options.htm#SaveColourScheme
1036,Colour_Options.htm#SetNewCustomDefault

I launch the the topics like this:

Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" _
(ByVal nSize As Long, _
ByVal lpBuffer As String) As Long


Function ContextID2Topic(lContextID As Long) As String

Dim arr
Dim i As Long

OpenTextFileToArraySplit strLocalDrive & _
":\RBSSynergyReporting\Help\ContextIDMap.txt",
_
arr, _
0

For i = 0 To UBound(arr)
If Val(arr(i, 0)) = lContextID Then
ContextID2Topic = arr(i, 1)
Exit For
End If
Next

End Function

Function ShowHelp(bWeb As Boolean, _
Optional lHelpID As Long = -1) As Boolean

Dim strTempFile As String
Dim strFolder As String
Dim strURL As String
Dim strTopic As String
Dim strMessage As String

On Error GoTo ERROROUT

strLocalDrive = Left$(Application.path, 1)

If lHelpID > -1 Then
strTopic = ContextID2Topic(lHelpID)
End If

If bWeb Then
strFolder = "http://www.rbs-software.co.uk/WebHelp/"
If lHelpID = -1 Then
strMessage = "Couldn't launch the Web Help"
Else
strMessage = "Couldn't launch help topic " & strTopic & " of the
Web Help"
End If
Else
strFolder = "file:///" & _
strLocalDrive & ":/RBSSynergyReporting/Help/WebHelp/"
If lHelpID = -1 Then
strMessage = "Couldn't launch the Local Help"
Else
strMessage = "Couldn't launch help topic " & strTopic & " of the
Local Help"
End If
End If

If lHelpID = -1 Then
strURL = strFolder & strNonContextFile
Else
strURL = strFolder & strNonContextFile & _
"#" & strTopic
End If

strTempFile = PrepareTempHtmlFile(strURL)

'run shell execute to launch default browser to view it
'------------------------------------------------------
If (ShellExecute(0&, _
"open", _
strTempFile, _
vbNullString, _
vbNullString, _
vbNormalFocus) > 32) Then
ShowHelp = True
Else
MsgBox strMessage, , "launching help"
ShowHelp = False
End If

Exit Function
ERROROUT:

ErrorToClipBoard

MsgBox strMessage & _
vbCrLf & vbCrLf & _
Err.Description & _
vbCrLf & _
"Error number: " & Err.Number, , "launching help"

ShowHelp = False
On Error GoTo 0

End Function

Private Function GetTempFile(strURL As String) As String

Dim strFile As String
Dim strTempPath As String
Dim lLength As Long

strTempPath = String$(MAX_PATH, vbNullChar)
lLength = GetTempPath(MAX_PATH, strTempPath)

If (lLength > 0) Then
strTempPath = Left(strTempPath, InStr(1, strTempPath, vbNullChar) -
1)
End If

strTempPath = Trim(strTempPath)
strFile = strTempPath & "TempHelp.htm"
GetTempFile = strFile

End Function

Private Function PrepareTempHtmlFile(strURL As String) As String

Dim strFile As String
Dim strTempFileFormatPart1 As String
Dim strTempFileFormatPart2 As String
Dim strTotalUrl As String
Dim FSO
Dim txtfile

strFile = GetTempFile(strURL)

'Chr(34) is a double quote "
'---------------------------
strTempFileFormatPart1 = "<html>" & vbCrLf & _
"<script language=" & Chr(34) & _
"Javascript" & Chr(34) & _
">" & vbCrLf & _
"<!--" & vbCrLf & _
"document.location=" & Chr(34)

strTempFileFormatPart2 = Chr(34) & ";" & vbCrLf & _
"//-->" & vbCrLf & _
"</script>" & vbCrLf & _
"</html>"

If (InStr(1, strURL, "://") = 0) Then
strURL = Replace(strURL, "\", "/")
strURL = "file://" + strURL
End If

strTotalUrl = strURL

Set FSO = CreateObject("Scripting.FileSystemObject")
Set txtfile = FSO.CreateTextFile(strFile, True)

txtfile.Write (strTempFileFormatPart1 & strTotalUrl &
strTempFileFormatPart2)
txtfile.Close

Set FSO = Nothing

PrepareTempHtmlFile = strFile

End Function


It may look complicated, but it works absolutely perfect, both for a webhelp
and also if the files are
locally on the harddrive.


RBS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top