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