WinHelp to HTMLHelp for Visual Basic - chm

I have inherited an old Visual Basic project. It still works except for the .hlp file on Windows 10.
I have found how I can convert the .hlp file to .chm.
Can anyone tell me how to replace the WinHelp with HTMLHelp in the VB project?
Thanks in advance

A correct answer depends on your exact requirements.
If you only want to start the old *.exe and display the *.hlp file (WinHelp) please navigate to the following link (search for Run WinHelp on Windows10) and read all further links inside:
How to convert HLP files into CHM files
Please note a tool called HHPMod especially for migrating context-sensitive F1 help. If F1 help has been used intensively in your old project, it can be difficult to switch from WinHelp (.hlp) to HTMLHelp (.chm).
But, you're already on the right track recommended ten years ago and still valid today "Help authors should move over to HTML Help 1.x (.chm)".
If you really want to recompile your old project then Download Visual Basic 6 example project may help you (see Download section).
First of all, you need to specify the help file that you want to use by setting e.g.:
App.HelpFile = App.Path & "\helpfile.chm"
You'll find all declarations in a module modHelp.bas like e.g.
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 Declare Function HTMLHelpTopic Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As String) As Long
Private Declare Function HtmlHelpSearch Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, dwData As HH_FTS_QUERY) As Long
Private Declare Function HtmlHelpIndex Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, dwData As HH_AKLINK) As Long
For further information see also Using a module for Visual Basic 6 projects

I have had success getting the Setup to install the WinHlp32 modules. I had to add some extra code into the Setup to get the modules to register.
I have only tried this on a couple of machines so far...
Thanks for your help.

Related

Declaring & Calling The Sleep API

I have read many threads on implementing the Sleep API however most are a step ahead of where I am at in terms of knowledge to some guidance would be greatly appreciated.
I have a macro in VBA which I would like to add pauses to, between steps (purely aesthetic rather than functional) however I am struggling with the basic declaring and calling.
I understand that first I must declare the api and that the code for this is...
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
however, I am confused with regards to where this should go. Should it go in a module of it's own or can it be stated at the top of the macro module?
Then to call the function do I simply add a line to the macro of...
Call Sleep (1000)
I'd appreciate it if anyone can help with this question and appreciate your patience with my basic grasp.
The declaration of Sleep should go to the top of a module. Standard coding module.
You can omit Call and just use
Sleep 1000 ' 1 second delay
anywhere within an existing sub, so
Option Explicit
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Main()
' wait 3 seconds
Sleep 3000
End Sub
an alternative without declaring the Sleep sub would be
Application.Wait Now + TimeValue("00:00:03") ' waits 3 seconds

Numlock and CAPSLOCK turned always ON in VBA Access

Hello i have a form written in VBA Access , when i type or select some values from comboboz or text some values, my NUMLOCK And CAPSLOCK key are turning OFF, how to make that they ALWAYS will be ON , i can't figure how?
this has code that will check and set capslock, numlock and scrolllock.
It uses the windows APIs
Private Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" _
(lppbKeyState As Byte) As Long
to check and set the keyboard state - with this API, other fun things are available, such as playing with the windows key.

How to get the idle time in Windows XP using VBA?

I would like to know the current idle time from user input on a given Windows XP machine programmatically. I am using VBA in MS Access. What options do I have?
I used the following to obtain the solution.
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetLastInputInfo Lib "user32" (plii As Any) As Long
Private Type LastInputInformation
cbSize As Long
dwTime As Long
End Type
Public Function GetUsersIdleTime() As Long
Dim lii As LastInputInformation
lii.cbSize = Len(lii)
Call GetLastInputInfo(lii)
GetUsersIdleTime = FormatNumber((GetTickCount() - lii.dwTime) / 1000, 2)
End Function
There are other parts of the system which can be idle such as,
CPU
Disk
Network
Other devices
To find out more regarding performance and other idle types see this SO post here.

ms-access import dll with ending backslash in dll path

I'm expecting to see a reference to VBscript Regular Expressions 5.5 by adding the path
c:\windows\system32\vbscript.dll\3 to ms-access via Tools > References. However the directory tree only shows me the full path without the ending "\3"
What does the "\3" mean (version number?), what is it the correct name for it?
How do correctly add this reference to my access project? Thanks.
Better yet, don't add a reference to it. Instead, use late binding. This means you'll use plain-vanilla object variables instead of the RegExp library's data types:
Dim objRegEx As Object
Set objRegEx = CreateObject("VBScript.Regexp")
Thus, you don't need to worry about the library version installed on the particular computer. The speed difference is pretty neglible for one call to it, but if you're going to use it regularly, create a public function like this:
Public Function RegEx() As Object
Static objRegEx As Object
If objRegEx Is Nothing Then
Set objRegEx = CreateObject("VBScript.Regexp")
End If
Set RegEx = objRegEx
End Function
Then you don't have to do anything at all -- just use RegExp the same way you'd use a variable that pointed to its top-level object. This will automatically initialize the first time you use it and will then persist until you close the application.
If you're concerned about cleaning up before closing down, you can do this:
Public Function RegEx(Optional bolClose As Boolean = False) As Object
Static objRegEx As Object
If bolClose Then
Set objRegEx = Nothing
Exit Function
End If
If objRegEx Is Nothing Then
Set objRegEx = CreateObject("VBScript.Regexp")
End If
Set RegEx = objRegEx
End Function
And in your app's shutdown routine call it thus:
Call RegEx(True)
And bob's your uncle!
bizl,
The \3 is a red herring.
To add the reference to your Access project, open any code window, select References from the Tools menu, scroll down to the entry illustrated below and check it.
Notice that the Location says \3, even though the DLL resides in the System32 directory. It has something to do with the way Microsoft versions things.
(source: windowsdevcenter.com)

How to Inspect Call Stack

Would it be possible to see the CallStack in VBA for MS Access 2003? That is to say, would it be possible to see from what procedure or function another function was called?
At runtime, View menu -> Call Stack (or press CTRL + L).
There is no programmatic way in VBA to view the call stack that I know of. The usual solution to this problem is to use some structure to track calling of functions, but it always seems like a kludge to me, and really of use only when programming (not at runtime), in which case it seems to me that the VBE's built-in capability for seeing the call stack is sufficient.
And, BTW, I always put the call stack button on my VBE toolbar, since it's one of the most frequently used functions for me. I also add the compile button -- I think it's crazy that it's not on the toolbar by default because it encourages people to code without ever forcing a compile. Then again, Access 2000 didn't even use Option Explicit by default (supposedly for consistency with the other apps using the VBE -- in other words, dumb down Access in order to make it consistent with apps that aren't nearly as code-heavy).
But I digress...
Eventually, add an optional parameter to your function, and pass the caller name that way. For forms, you can use Me.Name as the parameter.
Yes it's possible, BUT it's not quite usefull!
Private Declare Sub SetMode Lib "vba332.dll" Alias "EbSetMode" (ByVal lngMode As Long)
Private Declare Function GetCallStackCount Lib "vba332.dll" Alias "EbGetCallstackCount" (lngCount As Long) As Long
Private Declare Function GetCallStackFunction Lib "vba332.dll" Alias "EbGetCallstackFunction" (ByVal Lvl As Long, ByRef strBase As String, ByRef strModule As String, ByRef strFunction As String, ByRef Done As Long) As Long
Before use GetCallStackCount and GetCallStackFunction call SetMode(2), and after SetMode(1).