0
2

More than 3 years have passed since last update.

さくらエディタの複数マクロのロジックを一つのファイルにまとめる方法  その2

Last updated at Posted at 2020-06-06

はじめに

こちらで紹介した方法では、Editorオブジェクトにアクセスできないという致命的な問題があるので
別の方法を考えました。

方法

ラッパー用のvbsファイルに本体のファイルをincludeします

本体のサンプル

Test.vbs
Option Explicit
Sub Test1()
    Call MsgBox("Test1が実行されました")
End Sub

Sub Test2()
    Call MsgBox("Test2が実行されました")
End Sub

ラッパー用のファイルのサンプル

Test1.vbs
Option Explicit
Dim objShell, objFSO
Set objShell = CreateObject("WScript.Shell")
Set objFSO   = CreateObject("Scripting.FileSystemObject")
objShell.CurrentDirectory = objFSO.GetParentFolderName(Editor.ExpandParameter("$M"))
With objFSO.OpenTextFile("Test.vbs")
    ExecuteGlobal .ReadAll
    .Close
End With

Call Test1()
Test2.vbs
Option Explicit
Dim objShell, objFSO
Set objShell = CreateObject("WScript.Shell")
Set objFSO   = CreateObject("Scripting.FileSystemObject")
objShell.CurrentDirectory = objFSO.GetParentFolderName(Editor.ExpandParameter("$M"))
With objFSO.OpenTextFile("Test.vbs")
    ExecuteGlobal .ReadAll
    .Close
End With

Call Test2()

ラッパー用のファイルをマクロに登録します

image.png

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2