从应用程序对象运行 VBA 宏。 支持的平台:仅窗口 签名工 务 局: object.RunMacro MacroPath
返回值(RetVal)无返回值。 言论若要将宏与弹出菜单或工具栏项相关联,请使用属性。Macro 例子工 务 局: 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!")
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-30 07:16
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.