ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] onaction="Macro",macro¦³°Ñ¼Æ¦p¦ó¼g§r

[µo°Ý] onaction="Macro",macro¦³°Ñ¼Æ¦p¦ó¼g§r

onaction="Macro",macro¦³°Ñ¼Æ¦p¦ó¼g§r
lmh

§A¥i¥H§â§Aªº°ÝÃD¦b¨ãÅé¤@ÂIªº´y­z¶Ü¡H
³o¼Ë¦³ÂIÃø¦^µª§Aªº°ÝÃD¡A

¦pªG§A¬O«ü  Macro¬O¤@­ÓÅܼƪº¸Ü¡A
ª½±µ§âÂù¤Þ¸¹®³±¼§Y¥i¡C

¦pªGMacro¬O¤@­ÓSub­n²K¥[°Ñ¼Æªº¸Ü
Macro ÅܼÆA,ÅܼÆB,ÅܼÆC

¦pªGMacro¬O¤@­ÓFunction­n²K¥[°Ñ¼Æªº¸Ü
Macro(ÅܼÆA,ÅܼÆB,ÅܼÆC)

TOP

¦^´_ 1# mhl9mhl9

¬O­n°ÝCommandBarButton.OnAction ªº³¡¤À¶Ü¡H

TOP

¦^´_ 3# naruto018

yes ,§Ú¯u¬O·Q°Ýcommandbarªºcontrol¤¤ onaction="¥¨¶°¦WºÙ" ³o­Ó¥¨¶°ªº°Ñ¼Æ¥ô¦ó¼g?
lmh

TOP

¦^´_ 3# naruto018

yes °ÝCommandBarButton.OnAction ªº³¡¤À.
§Ú°µ¤F­Ócommandbar,¦³4­ÓButton,°õ¦æ¦P¤@­Ósub,¥u¬O°Ñ¼Æ¤À§O¬O1,2,3,4.
·íµM³Ì¦n¬O onaction=sub¦WºÙ+°Ñ¼Æ,¦ý¤£ª¾¦p¦ó¼g,¤£±o·N¨D¨ä¦¸,§Ú²{¦b¥Îapplication.caller(2),¤]ºÞ¥Î.¦p¤U:
   4­Ó¤@¼Ë onaction="abcd""
   sub abcd
    xxx=application.caller(2)
    ¥¨¶°¦W xxx
    end sub
¬d¨ìapplication.caller¬O­Ó¼Æ²Õ,¦³4­Ó¼Æ,1,1,4105,0,²Ä¤G¼Æ¦n¹³¥Nªí²Ä´X­Óbutton,©Ò¥H§Ú¥Î²Ä¤G­Ó¼Æ·í°Ñ¼Æ
¦ý¨s³º³o4­Ó¼Æ¥Nªí¤°»ò,¤£²M·¡,¤]¬d¤£¨ì,©Ò¥H°ÝÃD¦ü¥G¸Ñ¨M¤F,¦ý¦}¤£½ñ¹ê.
lmh

TOP

¦^´_ 5# mhl9mhl9

°Ñ¦Ò¬Ý¬Ý
  1. Public Const B1 As String = "text-B1"
  2. Public Const B2 As String = "text-B2"
  3. Public Const B3 As String = "text-B3"

  4. Public Sub abc()
  5.     With Application.CommandBars.Add("´ú¸Õ", msoBarTop, , True)
  6.         .Visible = True
  7.         With .Controls.Add(Type:=msoControlPopup) '°Ñ¼Æ¥N¤J¼Æ¦r
  8.             .Caption = "´ú¸Õ1"
  9.             With .Controls.Add(Type:=msoControlButton)
  10.                 .Caption = "´ú¸Õ0"
  11.                 .OnAction = "text" '¨S¥N¤J°Ñ¼Æ
  12.             End With
  13.             With .Controls.Add(Type:=msoControlButton)
  14.                 .Caption = "´ú¸Õ1-1"
  15.                 .OnAction = "'text 1'" '¥N¤J°Ñ¼Æ·|¦b­ì¥»³Ì¥~³òªºÂù¤Þ¸¹¸Ì­±¤À§O¥[³æ¤Þ¸¹
  16.             End With
  17.             With .Controls.Add(Type:=msoControlButton)
  18.                 .Caption = "´ú¸Õ1-2"
  19.                 .OnAction = "'text 1,2'" '¤£¦P°Ñ¼Æ¥Î³r¸¹¤À¶}
  20.             End With
  21.             With .Controls.Add(Type:=msoControlButton)
  22.                 .Caption = "´ú¸Õ1-3"
  23.                 .OnAction = "'text 1,2,3'"
  24.             End With
  25.         End With
  26.         With .Controls.Add(Type:=msoControlPopup) '°Ñ¼Æ¥N¤J¤å¦r
  27.             .Caption = "´ú¸Õ2"
  28.             With .Controls.Add(Type:=msoControlButton)
  29.                 .Caption = "´ú¸Õ2-1"
  30.                 .OnAction = "'text ""B1""'" '¤å¦r¥ª¥k°¼¤À§O¥[¤W¨â­ÓÂù¤Þ¸¹
  31.             End With
  32.             With .Controls.Add(Type:=msoControlButton)
  33.                 .Caption = "´ú¸Õ2-2"
  34.                 .OnAction = "'text ""B1"",""B2""'"
  35.             End With
  36.             With .Controls.Add(Type:=msoControlButton)
  37.                 .Caption = "´ú¸Õ2-3"
  38.                 .OnAction = "'text ""B1"",""B2"",""B3""'"
  39.             End With
  40.         End With
  41.         With .Controls.Add(Type:=msoControlPopup) '°Ñ¼Æ¥N¤JÅܼÆ
  42.             .Caption = "´ú¸Õ3"
  43.             With .Controls.Add(Type:=msoControlButton)
  44.                 .Caption = "´ú¸Õ3-1"
  45.                 .OnAction = "'text B1'"
  46.             End With
  47.             With .Controls.Add(Type:=msoControlButton)
  48.                 .Caption = "´ú¸Õ3-2"
  49.                 .OnAction = "'text B1,B2'"
  50.             End With
  51.             With .Controls.Add(Type:=msoControlButton)
  52.                 .Caption = "´ú¸Õ3-3"
  53.                 .OnAction = "'text B1,B2,B3'"
  54.             End With
  55.         End With
  56.     End With
  57. End Sub


  58. Public Sub text(Optional Arg1 = "A1", Optional Arg2 = "A2", Optional Arg3 = "A3")  '¹w³]¨S¥N¤J°Ñ¼Æªº¹w³]­È
  59. MsgBox Arg1 & Chr(10) & Chr(13) & Arg2 & Chr(10) & Chr(13) & Arg3
  60. End Sub
½Æ»s¥N½X

TOP

±N°Ñ¼Æ¼g¤J.Parameter¤¤¡Aµ{§Ç¦A¤Þ¥Î.Parameterªº­È¡A
¨ä¹ê¤]¥i¥H.Tag¥N´À¡A
¤]¥i¥H¦Û­qÅܼơA¼g¤JÅܼơA¦A¤Þ¥ÎÅܼơA¨ä¹ê³o¼Ë¤ñ¸ûÆF¬¡¡A§Ú³£¦Û­qÅܼơC
Word§e²{·¥­PªºÀRºA¤§¬ü¡AExcel®i²{·¥­Pªº°ÊºA¤§¬ü¡C

TOP

¦^´_ 7# linyancheng


    ½Ð¤j¤j¼g¤@¬qµ{¦¡ªº¨Ò¤l¡A¥H¸ê¼Ò¥é¾Ç²ß
ÁÂÁÂ

TOP

#2,#3,#6
ÁÂÁ¦U¦ìÀ°¦£,§Ú¨D§Uªº°ÝÃD¬Û«H¤£¤Ö¤H³£·Qª¾¹D,³o¨à§Ú¦A²³æ´£¤@´£:
·í§A°µcommandbarbutton,¨ä¤¤¦³¤@¥y"Onaction="sun¦WºÙ"",¦pªGsub¦WºÙ¦³°Ñ¼Æ¥ô¦ó¼g?
µª®×´N¬O#6§i¶Dªº  Onaction="'sub¦WºÙ °Ñ¼Æ'",´N¬OÂù¤Þ¸¹+³æ¤Þ¸¹+sub¦WºÙ+ªÅ®æ+°Ñ¼Æ+³æ¤Þ¸¹+Âù¤Þ¸¹,´N³o»ò²³æ.
¨ä¥L¤èªk¤]´£¨Ñ§Ú­Ì¤£¤Ö«ä¸ô,¦ý´N¤W­z¤@±ø,³Ì²³æ³Ì¦n¥Î,¦A¦¸ÁÂÁ¤j®a!
lmh

TOP

actioncontrol »P tag ªº¥Îªk °Ñ¦Ò Microsoft ºô­¶¦p¤U¡G
https://msdn.microsoft.com/en-us/vba/office-shared-vba/articles/commandbars-actioncontrol-property-office#example

TOP

        ÀR«ä¦Û¦b : ¬°¦Û¤v§äÂǤfªº¤H¥Ã»·¤£·|¶i¨B¡C
ªð¦^¦Cªí ¤W¤@¥DÃD