- 积分
- 103
- 明经币
- 个
- 注册时间
- 2014-4-14
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
各位老大,VB中用AddMenuItem调用SUB可以吗?下面是我在VB中的代码
Option Explicit
Public SAPCAD As AcadApplication
Sub Main()
On Error Resume Next
Set SAPCAD = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set SAPCAD = CreateObject("AutoCAD.Application")
If Err Then
MsgBox ("请安装CAD")
Exit Sub
End If
End If
SAPCAD.WindowState = acMax
Dim currmenugroup As AcadMenuGroup
Set currmenugroup = SAPCAD.Application.MenuGroups.Item(0)
'创建新菜单
Dim newmenu As AcadPopupMenu
Set newmenu = currmenugroup.Menus.Add("SAP接口1")
'在新菜单上增加菜单项
Dim newmenuitem1 As AcadPopupMenuItem
Dim newmenuitem2 As AcadPopupMenuItem
Dim SubMacro As String
SubMacro = Chr(3) & Chr(3) & Chr(95) & "call Create_bom" & Chr(32)
Set newmenuitem1 = newmenu.AddMenuItem(newmenu.Count + 1, "根据BOM生成明细表", SubMacro)
Set newmenuitem2 = newmenu.AddMenuItem(newmenu.Count + 1, "根据明细表生成BOM", SubMacro)
newmenu.InsertInMenuBar (SAPCAD.Application.MenuBar.Count + 1)
End Sub
Sub Select_material()
Dim s As String
MsgBox "select material"
End Sub
Sub Create_bom()
Dim s As String
MsgBox "select BOM"
End Sub
这样处理后,在CAD中菜单可以出来,可以点了菜单行后没有运行sub Create_bom,有劳老大们指点一下,谢谢!
该贴已经同步到 billyang99的微博 |
|