#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Help Files

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Help Files

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


"Apollyon" wrote in message
oups.com...
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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Navigating to Excel files over network slow, but not Word files Newbie123 Excel Discussion (Misc queries) 1 December 2nd 09 01:18 PM
How can I batch convert 97-2003 .xls files to 2007 .xlsx files Dave Nuttall Excel Discussion (Misc queries) 4 August 3rd 09 11:38 PM
Excel 2007 tmp files filling up drive with XLSM files Jim Excel Worksheet Functions 0 September 12th 08 03:31 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
converter tool to convert XL 2007 files to XL 2003 files Dave F Excel Discussion (Misc queries) 6 December 15th 06 12:45 AM


All times are GMT +1. The time now is 01:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"