jiavia 发表于 2008-5-16 16:41:00

如何调用自定义的宏

<p>大家好,本人刚刚接触这方面的知识,有个问题想请教一下</p><p>有下面的函数</p><p>Sub SetToolbarButton()<br/>&nbsp;&nbsp;&nbsp; Dim currMenuGroup As AcadMenuGroup<br/>&nbsp;&nbsp;&nbsp; Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; '建立一个新的工具栏<br/>&nbsp;&nbsp;&nbsp; Dim newToolbar As AcadToolbar<br/>&nbsp;&nbsp;&nbsp; Set newToolbar = currMenuGroup.Toolbars.Add("TestToolbar")<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; '在新工具栏上增加一个按钮<br/>&nbsp;&nbsp;&nbsp; Dim newButton As AcadToolbarItem<br/>&nbsp;&nbsp;&nbsp; Dim openMacro As String<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; '赋值这个宏的VB表达式为"ESC ESC _open "<br/>&nbsp;&nbsp;&nbsp; openMacro = Chr(3) + Chr(3) + Chr(95) + "open" + Chr(32)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Set newButton = newToolbar.AddToolbarButton("", "NewButton", "Open a file.", openMacro)</p><p>End Sub</p><p></p><p>上面代码能正常运行。但是我想在这里</p><p>Set newButton = newToolbar.AddToolbarButton("", "NewButton", "Open a file.", openMacro)</p><p>中的openMacro赋予自己的宏表达式GetTrueCoordinate(),如下面:</p><p>Sub GetTrueCoordinate()</p><p>&nbsp;&nbsp; MsgBox("Hello World!")</p><p>End Sub</p><p>请问怎么写呢。谢谢大家阿!!!!</p>

azjmjsj 发表于 2008-5-17 00:20:00

<p>Set newButton =<br/>newToolbar.AddToolbarButton(1, "新功能", "新功能", "-vbarun GetTrueCoordinate" &amp; vbCr) </p>

jsxygshh 发表于 2012-11-16 09:53:16

正在找,终于找到了,谢谢AZJMJSJ
页: [1]
查看完整版本: 如何调用自定义的宏