0
我已经找到了如何创建按钮,并且当我按下它时,它会执行以下功能。Powerpoint在按钮上附加VBA功能
< -Button->
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
<清议,我想它perform->
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
难道你知道我怎么能这样做呢?
我这样做,它似乎正确的事情。但是当我运行它时,运行时错误为'5'。我是否需要单独保存模块或保存在同一个文件中?谢谢您的回答,不管怎样,我还不是程序员!我不知道为什么有时会创建此按钮,有时它会给您一个运行时错误.. – user1022143 2013-05-22 10:50:10
当我尝试调试它时,它停在这一行: Set cb = Application.CommandBars.Add(“additional_toolbar”,msoBarTop,,True 你知道它有什么问题吗? – user1022143 2013-05-22 11:01:14
如果命令栏当你尝试添加它的时候,你会得到一个错误,如果它发生,你需要捕获错误。 – 2013-05-22 11:41:03