Nhờ sửa lỗi VBA không gán macro cho shap (2 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

Tôi tuân thủ nội quy khi đăng bài

thaibaoanh

Thành viên mới
Tham gia
4/7/23
Bài viết
13
Được thích
1
Mình có một đoạn code VBA trên PPT để thêm một shape lên slide PPT, để chạy một macro khi trình chiếu.
Khi lưu nó ở dạng pptm thì chạy, khi lưu sang ppam thì lỗi ở phần gán macro
Mã:
Sub AddButton1()
    Dim pptPres As Presentation
    Dim PPTSld As slide
    Dim PPTShp As shape
    
    Set pptPres = ActivePresentation
    Set PPTSld = pptPres.Slides(ActiveWindow.Selection.SlideRange.SlideNumber)
    
    Set PPTShp = PPTSld.Shapes.AddShape(msoShapeRoundedRectangle, 750, 100, 100, 50)
    PPTShp.Fill.ForeColor.RGB = RGB(255, 255, 255)
    PPTShp.Line.ForeColor.RGB = RGB(0, 0, 0)
    
    With PPTShp.TextFrame.TextRange
        .text = "Countdown"
        .Font.size = 14
        .Font.Bold = True
        .Font.Color.RGB = RGB(0, 0, 0)
        .ParagraphFormat.Alignment = ppAlignCenter
    End With
    
    PPTShp.ActionSettings(ppMouseClick).Action = ppActionRunMacro
    PPTShp.ActionSettings(ppMouseClick).Run = "FCdown1"
End Sub
Và lỗi
Mã:
Run-time error '-2147188160 (80048240)':
ActionSetting (unknown member): Invalid request.
Hai dòng gán macro
Mã:
PPTShp.ActionSettings(ppMouseClick).Action = ppActionRunMacro

    PPTShp.ActionSettings(ppMouseClick).Run = "FCdown1"
kết quả là có shape kèm lỗi trên, không gán đc macro
Nhờ mọi người sửa lỗi để chạy đc trên ppam
 
Web KT

Bài viết mới nhất

Back
Top Bottom