bryki 发表于 2007-5-24 14:45:00

[求助]怎麽讓菜單項響應窗體啊~

<p>&gt;.&lt;</p><p>我做了個窗體...直接在那個那個打VBAIDE進去的那個什麽來著可以運行得</p><p>然後我又找了段加菜單的代碼...也可以的</p><p>但是找不到菜單響應窗體事件的代碼..</p><p>就是比如我加了菜單項叫ENJOY(&amp;E)的..然後怎麽能點這個菜單就跳出我已經編好的一個窗體....我只找的到那個OPEN的...</p><p>請高手們幫幫忙...告訴我下改在哪寫些什麽代碼</p>

laoliu09 发表于 2007-5-24 15:55:00

<p>楼上的是哪里的朋友啊?幸亏我还懂得繁体字!呵呵!菜单只能运行一个宏,所以需要点击菜单运行窗体,就把窗体启动代码写作一个宏里面!</p><p>例如</p><p>sub form_show()</p><p>useform1.show</p><p>end sub</p><p>用菜单启动上面的宏即可!</p>

烟雨.江南 发表于 2007-5-24 17:45:00

<p>实际上在菜单的命令行写上: </p><p>vbastmt userform.show </p><p>就可以了。</p>

laoliu09 发表于 2007-5-24 18:52:00

vbastmt?呵呵!原来还有这个东东啊,又学习了!

bryki 发表于 2007-5-27 01:40:00

laoliu09发表于2007-5-24 15:55:00static/image/common/back.gif楼上的是哪里的朋友啊?幸亏我还懂得繁体字!呵呵!菜单只能运行一个宏,所以需要点击菜单运行窗体,就把窗体启动代码写作一个宏里面!例如sub form_show()useform1.showend sub用菜单启动上面

<p></p>

bryki 发表于 2007-5-27 01:45:00

烟雨.江南发表于2007-5-24 17:45:00static/image/common/back.gif实际上在菜单的命令行写上: vbastmt userform.show 就可以了。

<p></p><p>&gt;.&lt;不行诶...出错..</p><p>我菜单的代码是这样的</p><p>Public Sub TextInsertMenu()<br/>Dim Cumegr As AcadMenuGroup<br/>Set Cumegr = ThisDrawing.Application.MenuGroups.Item(0)<br/>Dim newmenu As AcadPopupMenu<br/>Set newmenu = Cumegr.Menus.Add("TextInsert(&amp;X)")<br/>newmenu.InsertInMenuBar (ThisDrawing.Application.MenuBar.Count + 1)<br/>End Sub<br/></p>

紫色狂澜 发表于 2007-5-27 13:21:00

<font color="#0000ff"><p>&nbsp; ' 定义当前菜单组的变量<br/>&nbsp; &nbsp; Dim currMenuGroup As AcadMenuGroup<br/>&nbsp; &nbsp; Set currMenuGroup = ThisDrawing.Application. _<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MenuGroups.Item(0)<br/>&nbsp; &nbsp; <br/>&nbsp; &nbsp; ' 创建新菜单<br/>&nbsp; &nbsp; Dim newMenu As AcadPopupMenu<br/>&nbsp; '---------------------------------------------------------------------------------------------<br/>&nbsp; &nbsp; Set newMenu = currMenuGroup.Menus.Add("KKS处理")<br/>&nbsp; &nbsp; <br/>&nbsp; &nbsp; ' 声明表示菜单项的变量<br/>&nbsp; &nbsp; Dim newMenuItem As AcadPopupMenuItem<br/><br/>&nbsp; &nbsp; ' 并创建菜单项<br/>&nbsp; &nbsp; Set newMenuItem = newMenu.AddMenuItem(newMenu.Count + 1, _<br/>&nbsp; &nbsp; &nbsp; &nbsp; "填充KKS码到块属性", "-VBARUN ShowUserForm" &amp; vbCr)&nbsp;&nbsp; '将菜单与宏对应<br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; ' 在菜单栏上显示菜单<br/>&nbsp; &nbsp; On Error Resume Next<br/>&nbsp; &nbsp; currMenuGroup.Menus.InsertMenuInMenuBar "KKS处理", ""<br/>'------------------------------------------------------------------------------------------------<br/><br/>End Sub<br/><br/><br/>Sub ShowUserForm()<br/>UserForm.Show</p><p>End Sub</p><p></p><p>把菜单中的文字换成你的就行了</p></font>

bryki 发表于 2007-5-28 09:57:00

<p>终于好了....谢谢你哈~</p>
页: [1]
查看完整版本: [求助]怎麽讓菜單項響應窗體啊~