Giúp tạo Button chứa lệnh VBA trên Powerpoint

thaibaoanh

Yêu THVBA
Nhờ mọi người giúp bài toán này:
Tạo 1 nút lệnh gọi form lên slide PPT như sau:
Khi ta nhấn vào lệnh chèn "Button" thì một button xuất hiện trên slide PPT , khi trình chiếu nhấn vào button này để gọi một form
Cảm ơn
 
Sửa lần cuối:

bluestar

Yêu THVBA
Nhờ mọi người giúp bài toán này:
Tạo 1 nút lệnh gọi form lên slide PPT như sau:
Khi ta nhấn vào lệnh chèn "Button" thì một button xuất hiện trên slide PPT , khi trình chiếu nhấn vào button này để gọi một form
Cảm ơn
Xem thử code này. Tạo shape trên Slide và gắn Macro AddShape cho nó.
Mã:
Sub ADDSHAPE()
Dim pppres As Presentation
Dim pslide As Slide
Dim pshp As Shape

Set pppres = ActivePresentation
Set pslide = pppres.Slides(1)
Dim x, y
x = Int((300 * Rnd) + 1)
y = Int((500 * Rnd) + 1)
Set pshp = pslide.Shapes.ADDSHAPE(msoShapeRectangle, Left:=x, Top:=y, Width:=100, Height:=40)
pshp.TextFrame.TextRange.Text = "CLICK ME!"
With pshp.ActionSettings(ppMouseClick)
         .Action = ppActionRunMacro
         .Run = "HienForm"
         .AnimateAction = msoCTrue
End With
 
End Sub
Sub HienForm()
    UserForm1.Show
End Sub
 

thaibaoanh

Yêu THVBA
Xem thử code này. Tạo shape trên Slide và gắn Macro AddShape cho nó.
Mã:
Sub ADDSHAPE()
Dim pppres As Presentation
Dim pslide As Slide
Dim pshp As Shape

Set pppres = ActivePresentation
Set pslide = pppres.Slides(1)
Dim x, y
x = Int((300 * Rnd) + 1)
y = Int((500 * Rnd) + 1)
Set pshp = pslide.Shapes.ADDSHAPE(msoShapeRectangle, Left:=x, Top:=y, Width:=100, Height:=40)
pshp.TextFrame.TextRange.Text = "CLICK ME!"
With pshp.ActionSettings(ppMouseClick)
         .Action = ppActionRunMacro
         .Run = "HienForm"
         .AnimateAction = msoCTrue
End With

End Sub
Sub HienForm()
    UserForm1.Show
End Sub
Lưu file pptm thì nó chạy đc, lưu file ppam thì nó lỗi, ko chạy đc
Mã:
Run-time error '-2147188160 (80048240)':
ActionSetting (unknown member): Invalid request.
 
Sửa lần cuối:
Top