CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

RunMacro Method (ActiveX)

2023-1-4 04:05| 发布者: admin| 查看: 599| 评论: 0|来自: AutoCAD

摘要: 从应用程序对象运行 VBA 宏。

从应用程序对象运行 VBA 宏。

支持的平台:仅窗口

签名

工 务 局:

object.RunMacro MacroPath
对象

类型:应用

此方法适用的对象。

宏路径

访问:仅输入

类型:字符串

一个字符串,表示要运行的宏的调用序列。调用序列必须具有以下语法,其中表示可选参数:[]

[Filename.dvb.][ProjectName.][ModuleName.]MacroName
注意:如果后跟Filename.dvb,则用感叹号而不是句点分隔名称,如以下示例所示:ProjectName
Filename.dvb!ProjectName

如果指定的文件名.dvb尚未加载,则将加载它。如果未指定文件名.dvb的路径,则会搜索 AutoCAD 搜索路径以查找文件。如果未指定 ifis,将搜索所有当前加载的项目以找到宏。ProjectName

返回值(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!")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-11 23:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部