20170813pptVBA批量插入图片

Posted Excel VBA 小天地

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

  

以上是关于20170813pptVBA批量插入图片的主要内容,如果未能解决你的问题,请参考以下文章

将多套图片批量分别插入对应的word中

图片如何批量插入到Excel表格中?用Html公式太复杂了,这才是最简单方法!

word批量插入图片及批量修改大小

Word批量调整插入图片大小

Excel批量插入图片

word用vba批量导入图片文件时,怎样保留图片原有大小,而不是统一固定大小?跪谢!下为您原来提供的代码