VBA(一)操作PPT中的图片和表格

向PPT粘贴图片和表格数据

Sub CopyPictureToPPT()
    Set ppt = New PowerPoint.Application
    ppt.Presentations.Open "C:\Users\Administrator\Desktop\testforAutopadding\testForPicture.pptx", WithWindow:=msoFalse
    '插入图片'
    ppt.Presentations(1).Slides(1).Shapes(1).Fill.UserPicture ("C:\Users\Administrator\Desktop\testforAutopadding\" & "red.jpg")''
    ppt.Presentations(1).Slides(1).Shapes(2).Fill.UserPicture ("C:\Users\Administrator\Desktop\testforAutopadding\" & "blue.jpg")
    '插入表格数据'
    Dim oWs As Worksheet'新建工作表'
    Set oWs = ActiveWorkbook.Worksheets(1)'将当前活动工作簿的工作表1赋给oWs变量'
    '将当前打开的Excel中的表格数据粘贴给PPT中的表格'
    With ppt.Presentations(1).Slides(2).Shapes(2).Table
    .Cell(1, 1).Shape.TextFrame.TextRange.Text = oWs.Cells(1, 1)
    End With
    '保存PPT并关闭'
    With ppt.Presentations(1)
        .Save
    End With
    Set oWs = nothing
    ppt.Quit
    Set ppt = nothing
End Sub
  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值