0
我是新来的powerpoint vba编程。我遇到了一个问题,我有一个宏脚本,它基本上将路径指向我的图像所在的文件夹,然后每个幻灯片放置一个图像。 现在我想要宏脚本来提示用户是否将4或6或8图像放在幻灯片中。这是我很期待的输出如下:导入图像并将它们放置在一个数组中的Powerpoint
我知道,这可以通过“插入画册”来完成,但问题是它只有对每张幻灯片的四个图像选项。所以这就是我写宏的原因。 这是我使用的代码:
Sub CreatePictureSlideshow()
Dim presentation
Dim layout
Dim slide
Dim FSO
Dim folder
Dim file
Dim folderName
' Set this to point at the folder you wish to import JPGs from
' Note: make sure this ends with a backslash \
folderName = "C:\Users\hamanda\Desktop\B2_images\"
' Delete all slides and setup variables
Set presentation = Application.ActivePresentation
If presentation.Slides.Count > 0 Then
presentation.Slides.Range.Delete
End If
Set layout = Application.ActivePresentation.SlideMaster.CustomLayouts(1)
Set FSO = CreateObject("Scripting.FileSystemObject")
' Retrieve the folder's file listing and process each file
Set folder = FSO.GetFolder(folderName)
For Each file In folder.Files
' Filter to only process JPG images
If LCase(Mid(file.Name, Len(file.Name) - 3, 4)) = ".png" Then
' Create the new slide and delete any pre-existing contents
Set slide = presentation.Slides.AddSlide(presentation.Slides.Count + 1, layout)
While slide.Shapes.Count > 0
slide.Shapes(1).Delete
Wend
' Add the picture
slide.Shapes.AddPicture folderName + file.Name, False, True, 10, 10
' Optional: create a textbox with the filename on the slide for reference
' Dim textBox
' Set textBox = slide.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 10, 200, 200)
' textBox.TextFrame.TextRange.Text = file.Name
End If
Next
End Sub
所以现在我如何可以修改此用于在滑动帮我这个
我会尝试,让你知道 – ayaan 2014-10-08 09:39:20
我已经运行它给出运行时错误424的代码:需要对象。您好,以解决这个问题 – ayaan 2014-10-08 09:44:20
你有没有使用f9代码?如果是的话,你在哪里得到错误? – 2014-10-08 09:45:52