To access all these facilities, you first need to download the file scrptlet.dsm
from our Web site
http://rapid.wrox.co.uk/books/138X
This file includes all the macros described here. Alternatively, you could also retype it manually. The full source code is:
Sub InsertVBScript()
if Not IsHTML() Then
Exit Sub
end if
Dim crlf
crlf = Chr(13) + Chr(10)
ActiveDocument.Selection = crlf + "<SCRIPT language=VBScript>" + crlf + _
"Sub Proc" + crlf + "End Sub" + crlf+ "</SCRIPT>"
End Sub
Sub InsertJScript()
if Not IsHTML() Then
Exit Sub
end if
Dim crlf
crlf = Chr(13) + Chr(10)
ActiveDocument.Selection = crlf + "<SCRIPT language=JScript>" + crlf + _
"function Proc() {" + crlf + "}" + crlf+ "</SCRIPT>"
End Sub
Sub InsertEvent()
if Not IsHTML() Then
Exit Sub
end if
Dim crlf
crlf = Chr(13) + Chr(10)
s1 = "<SCRIPT language=VBScript "
s2 = "for=document event=onclick>"
ActiveDocument.Selection = crlf + s1 + s2+ crlf + crlf + "</SCRIPT>"
End Sub
Sub InsertObject()
if Not IsHTML() Then
Exit Sub
end if
Dim crlf
crlf = Chr(13) + Chr(10)
s1 = "<OBJECT data=file.htm width=100 height=100 "
s2 = "type=text/x-scriptlet>"
ActiveDocument.Selection = crlf + s1 + s2+ crlf + crlf + "</OBJECT>"
End Sub
Sub PreviewPage()
if Not IsHTML() Then
Exit Sub
end if
Application.ExecuteCommand "EditPreviewHTMLPage"
End Sub
Sub RunWizard()
s = InputBox( "Type the name of the scriptlet you want the wizard to generate.", _
"Scriptlet Wizard", "MyScriptlet" )
Set NewDoc = Application.Documents.Add("Text")
NewDoc.Language = "HTML - IE 3.0"
NewDoc.Save ,True
ActiveDocument.Selection = s
Application.ExecuteCommand "UserTool7"
End Sub
Function IsHTML()
On Error Resume Next
if ActiveDocument.Type = "Text" Then
if ActiveDocument.Language <> "HTML - IE 3.0" Then
MsgBox "This macro can be used only with HTML files!", _
vbInformation, "Scriptlet Toolbar"
IsHTML = False
Exit Function
end if
end if
IsHTML = True
End Function
As well as the macro file, you also need the file scrltwiz.zip
, which includes the wizard. Again, you can download it from our website.
Once you have it all, then:
scrptlet.dsm
into the SHAREDIDE\MACROS
directory of the Visual Studio installation path.$(CurText)
.By this point, we have created a more comfortable environment in which to write and test scriptlets. However, even if you don't have Developer Studio you can still exploit the wizard.
In the next paragraph we'll show you how to use the wizard and how to create the skeleton for a complete scriptlet.