20170813pptVBA批量插入图片

Sub AddSldIn()
    Dim Pre As Presentation
    Dim NewSld As Slide

    Set Pre = Application.ActivePresentation
    Set NewSld = Pre.Slides.Add(Pre.Slides.Count + 1, ppLayoutBlank)

    Set Pre = Nothing
    Set NewSld = Nothing
End Sub
Sub AddTextBox()
    Dim Pre As Presentation
    Dim NewSld As Slide
    Dim Shp As Shape
    Dim Pos As Long
    Dim Tr As TextRange

    Set Pre = Application.ActivePresentation
    Set NewSld = Pre.Slides(1)
    With NewSld
        Set Shp = .Shapes.AddTextBox(msoTextOrientationHorizontal, Pre.PageSetup.SlideWidth / 2, 0, Pre.PageSetup.SlideWidth / 2, Pre.PageSetup.SlideHeight / 6)
        With Shp
            .TextFrame.WordWrap = msoTrue
            With .TextFrame.TextRange
                With .ParagraphFormat
                    .LineRuleWithin = msoTrue
                    .SpaceWithin = 1
                    .LineRuleBefore = msoTrue
                    .SpaceBefore = 0.5
                    .LineRuleAfter = msoTrue
                    .SpaceAfter = 0
                End With
                myText = "水平文本框" + Chr$(CharCode:=13) + "红色加粗"
                .Text = myText
                Pos = InStr(myText, Chr(13))
                Set Tr = .Characters(Pos + 1, Len(myText) - Pos)
                With Tr
                    .Font.Size = 36
                    .Font.Color.RGB = RGB(Red:=255, Green:=51, Blue:=0)
                End With
            End With
        End With

    End With
    Set Pre = Nothing
    Set NewSld = Nothing
End Sub
Sub InsertPicture()
    Dim Pre As Presentation
    Dim NewSld As Slide
    Dim Shp As Shape
    Dim FilePath As String
    Set Pre = Application.ActivePresentation
    Set NewSld = Pre.Slides(1)

    Set Shp = NewSld.Shapes.AddPicture(FilePath, msoFalse, msoTrue, 71, -21, 579, 584)

    Set Pre = Nothing
    Set NewSld = Nothing
    Set Shp = Nothing
End Sub
Function CustomLeft(ByVal Pre As Presentation, ByVal Pos As Long) As Double

End Function

  

转载于:https://www.cnblogs.com/nextseven/p/7355489.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值