WSHマクロにおいてWindows Script Component(*.wsc)を使用することで 各種スクリプトを混在で利用できます。
wscファイル内では、Editorオブジェクトが見えないので、 呼び出し元からEditorオブジェクトを渡す必要があります。
<?xml version="1.0"?> <component> <public> <method name="InsTextVBS"> <PARAMETER name="Editor"/> <PARAMETER name="sBuf"/> </method> <method name="InsTextJS"> <PARAMETER name="Editor"/> <PARAMETER name="sBuf"/> </method> </public> <script language="VBScript"> <![CDATA[ Sub InsTextVBS(Editor, sBuf) 'VBSエンジンによる処理 Editor.InsText(Cstr(sBuf)) End Sub ]]> </script> <script language="JScript"> <![CDATA[ function InsTextJS(Editor, sBuf) { //JSエンジンによる処理 Editor.InsText(sBuf + ''); } ]]> </script> </component>
WSC_PATH = "L:\func.wsc" Set oFunc=GetObject("Script:" & WSC_PATH) Call oFunc.InsTextJS(Editor, "By JScript") Set oFunc = Nothing
var WSC_PATH = "L:\\func.wsc"; var oFunc = GetObject("Script:" + WSC_PATH); oFunc.InsTextVBS(Editor, "By VBScript");