0

我已经找到了如何创建一个按钮并且我想制作它,所以当我按下它时它会执行以下功能。

<-按钮->

Sub AddButton()
   Dim cb As CommandBar

   Set cb = Application.CommandBars.Add("additional_toolbar", msoBarTop, , True)

   With cb.Controls.Add(msoControlButton)
      .Caption = "click me"
      .OnAction = "macro_name"
      .Style = msoButtonCaption
   End With
   cb.Visible = True
End Sub

<-我希望它执行的操作->

Sub CopySizeAndPosition()

    ' Usage: Select two shapes. The size and position of
    ' the first shape selected will be copied to the second.

    Dim w As Double
    Dim h As Double
    Dim l As Double
    Dim t As Double

    With ActiveWindow.Selection.ShapeRange(1)
        w = .Width
        h = .Height
    End With
    With ActiveWindow.Selection.ShapeRange(2)
        .Width = w
        .Height = h
    End With

End Sub

你知道我该怎么做吗?

4

1 回答 1

1

改变:

.OnAction = "宏名"

至:

.OnAction = "CopySizeAndPosition"

于 2013-05-03T02:19:50.377 回答