Donald Duck
Donald Duck

Reputation: 8882

Open a .chm from a hta

I have an HTA for which I've made a .chm help file. I want a JavaScript or a VBScript function to open a .chm file from the HTA to be able to make a help button like this:

<button onclick="//I don't know what to put here">Help</button>

How do I do this?

Upvotes: 1

Views: 582

Answers (1)

Hackoo
Hackoo

Reputation: 18827

In vbscript with HTA we can make it like this :

<html>
<Title>How to open VBSCRIP5.CHM</Title>
<head>
<HTA:APPLICATION
ICON="cmd.exe"
APPLICATIONNAME = "How to open VBSCRIP5.CHM"
BORDER="dialog"
BORDERSTYLE="complex"
>
<style>
body{
background-color: DarkOrange;
}
</style>
</head>
<script type="text/Vbscript">
Sub OpenCHMFile()
Dim CHMFile
CHMFile = "C:\Program Files\Microsoft Office\Office12\1036\VBSCRIP5.CHM"
Call Launch(CHMFile)
End Sub
'********************************************
Sub Launch(MyProgram)
Dim ws,Result
Set ws = CreateObject("wscript.Shell")
Result = ws.run(DblQuote(MyProgram),1,False)
End Sub
'********************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************
</script>
<body text="white">
<center>
<input type="button" onClick="OpenCHMFile()" value="Open the help file">
</center>
</body>
</html>

Upvotes: 1

Related Questions