Application オブジェクトから VBA マクロを実行します。
サポートされているプラットフォーム: Windows のみ
VBA:
object.RunMacro MacroPath
タイプ: Application
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ
タイプ: 文字列
実行するマクロの呼び出しシーケンスを示す文字列。呼び出しシーケンスには次の構文がなければなりません。ここで、[] はオプションのパラメータであることを示しています。
[Filename.dvb.][ProjectName.][ModuleName.]MacroName
Filename.dvb!ProjectName
指定された Filename.dvb は、ロード済みでない場合にロードされます。Filename.dvb へのパスが指定されていない場合、AutoCAD の検索パスを調べてファイルを見つけます。ProjectName が指定されていない場合は、現在ロードされているすべてプロジェクトを検索して、マクロを見つけます。
戻り値はありません。
ポップアップ メニューまたはメニュー項目にマクロを関連付けるには、Macro プロパティを使用します。
VBA:
Sub Example_RunMacro()
' This example loads a DVB file and runs a macro
' contained in the file using the RunMacro method.
'
' This example uses a DVB file named drawline.dvb.
' You should change the example to use a file on your computer.
'
' * Note: If you open a DVB file and then run the example to load it, there will be an error
' when the DVB file is unloaded.
Dim FileName As String
FileName = "c:\drawline.dvb"
' Load a sample VBA project DVB file
LoadDVB FileName
' Run the drawline sample macro
RunMacro "Module1.Drawline"
' Unload the drawline VBA project DVB file now that we are done
UnloadDVB FileName
MsgBox "The DVB file has been run!"
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_RunMacro()
;; This example loads a DVB file and runs a macro
;; contained in the file using the RunMacro method.
;;
;; This example uses a DVB file named drawline.dvb.
;; You should change the example to use a file on your computer.
;;
;; * Note: If you open a DVB file and then run the example to load it, there will be an error
;; when the DVB file is unloaded.
(setq acadObj (vlax-get-acad-object))
(setq fileName (findfile ".\\Sample\\VBA\\drawline.dvb"))
;; Load a sample VBA project DVB file
(vla-LoadDVB acadObj fileName)
;; Run the drawline sample macro
(vla-RunMacro acadObj "Module1.Drawline")
;; Unload the drawline VBA project DVB file now that we are done
(vla-UnloadDVB acadObj fileName)
(alert "The DVB file has been run!")
)