luhongwei 发表于 2017-12-10 16:50:01

求助PPT VBA 无法将图片导入幻灯片中,请帮忙看看,万分感谢,代码如下

Dim found As Boolean, n As Byte, i As Byte, adre$, tpadr$


On Error Resume Next
adre = InputBox("请输入图片存放的路径", "图片地址")
tpadr = Dir(adre & "*.jpg")
Do


' For n = 1 To 3
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutTitle).SlideIndex
Set tpadrs = ActiveWindow.View.Slide.Open(tpadr)
' Do
' found = False
' For Each Sld In ActivePresentation.Slides
' For Each shp In Sld.Shapes
' If shp.HasTextFrame Then
' If shp.Type1 Then
' If Not shp.TextFrame.HasText Then
' ActiveWindow.View.GotoSlide Index:=shp.Parent.SlideIndex
' shp.Select
' shp.Delete
' found = True
' End If
' End If
' End If
' Next shp
' Next Sld
' Loop While found = True

ActiveWindow.Selection.SlideRange.Shapes.AddPicture(tpadr, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=20, Top:=20, Width:=500, Height:=500).Select

' Next
tpadr = Dir
Loop Until Len(tpadr) = 0
End Sub

hai001xin 发表于 2018-1-12 10:10:02

PPT学习论坛,顶一下。
页: [1]
查看完整版本: 求助PPT VBA 无法将图片导入幻灯片中,请帮忙看看,万分感谢,代码如下