Image 在VBA中,如何顺序向每张幻灯片添加图像?

Image 在VBA中,如何顺序向每张幻灯片添加图像?,image,vba,loops,powerpoint,Image,Vba,Loops,Powerpoint,我需要在演示文稿中的每张幻灯片中添加一系列编号为0-1400的图像,以56(0、56、112等)为步长,然后使背景透明 到目前为止,我已经: Sub InsertImage() ActiveWindow.Selection.SlideRange.Shapes.AddPicture( _ FileName:="C:\Folder\Image0.bmp", _ LinkToFile:=msoFalse, _ SaveWithDocument:=msoTrue, Left:=25, Top:=

我需要在演示文稿中的每张幻灯片中添加一系列编号为0-1400的图像,以56(0、56、112等)为步长,然后使背景透明

到目前为止,我已经:

Sub InsertImage()

ActiveWindow.Selection.SlideRange.Shapes.AddPicture( _
 FileName:="C:\Folder\Image0.bmp", _
 LinkToFile:=msoFalse, _
 SaveWithDocument:=msoTrue, Left:=25, Top:=90, _
 Width:=265, Height:=398.5).Select

End Sub

Sub MakeTransparent()

  With ActiveWindow.Selection.ShapeRange
     .PictureFormat.TransparentBackground = msoTrue
     .PictureFormat.TransparencyColor = RGB(41, 41, 241)
     .Fill.Visible = msoFalse
  End With

End Sub
哪一个会单独做,但这并不比一个接一个地做快

非常感谢您的帮助

谢谢


Lauren

假设您想从幻灯片1开始,并且演示文稿中已经有足够多的幻灯片来包含所有图像,请尝试以下操作(总空气代码):


啊,太棒了。我以前从未使用过VBA,所以有一个简洁的答案很好。谢谢:-)太好了。。。很高兴能帮忙。您还需要额外的分数,以清楚地说明您的问题,并显示您尝试更新的代码。让我们的工作轻松多了。;-)
Sub InsertImages()

Dim lImageNumber as Long
Dim lSlideNumber as Long 
Dim oSh as Shape

lSlideNumber = 1  ' Slide counter

For lImageNumber = 0 to 1400 Step 56
   Set oSh = ActivePresentation.Slides(lSlideNumber).Shapes.AddPicture( _
     FileName:="C:\Folder\Image" & cstr(lImageNumber) & ".bmp", _
     LinkToFile:=msoFalse, _
     SaveWithDocument:=msoTrue, Left:=25, Top:=90, _
     Width:=265, Height:=398.5)

     lSlideNumber = lSlideNumber + 1

    With oSh
     .PictureFormat.TransparentBackground = msoTrue
     .PictureFormat.TransparencyColor = RGB(41, 41, 241)
     .Fill.Visible = msoFalse
    End With

Next

End Sub