PowerPoint VBA:哪个命令(或一组命令)会从我的.jpg图片中创建ppt帧?

bri*_*ant 4 scripting image frames paste powerpoint-vba

我在C:\ my_folder中有几个.jpg文件

以下是他们的名字:pic_1.jpg,pic_2.jpg,pic_3.jpg,pic_4.jpg,pic_5.jpg.

我应该使用Power Point VBA中的哪些命令或一组命令,以便能够在PowerPoint中自动创建多个帧,以便每个帧包含一个图片?

Avi*_*ilo 6

此VBScript创建一个新的PowerPoint演示文稿,并添加两个幻灯片,每个幻灯片都有一个图片.您需要根据自己的喜好调整图片的位置和大小.如果您想自动抓取目录中存在的任何图片以嵌入到演示文稿中,您还需要利用Scripting.FileScriptingObject来枚举您的图像.如果您希望脚本也可以pptPresentation.SaveAs在生成幻灯片后通过调用来保存演示文稿.

MSDN文档位于http://msdn.microsoft.com/en-us/library/ff746873.aspx.

Dim pptDoc
Dim pptPresentation
Dim pptSlide

Set pptDoc = WScript.CreateObject( "PowerPoint.Application" )
pptDoc.Visible = True
Set pptPresentation = pptDoc.Presentations.Add( True )

' Add a new slide with a blank layout to the end of the Slides collection
' 12 = ppLayoutBlank
Set pptSlide = pptPresentation.Slides.Add( pptPresentation.Slides.Count + 1, 12 )

' Add a picture into the slide, saving the picture into the PowerPoint document
' 10, 10 are the Left and Top coordinates respectively
pptSlide.Shapes.AddPicture "c:\FullPath\1.JPG", False, True, 10, 10

' Add another slide with a picture
Set pptSlide = pptPresentation.Slides.Add( pptPresentation.Slides.Count + 1, 12 )
pptSlide.Shapes.AddPicture "c:\FullPath\2.jpg", False, True, 10, 10
Run Code Online (Sandbox Code Playgroud)