Translate Blog

Monday, November 15, 2010

Insert multiple pictures into Powerpoint slides in less than 1 minutes


Let say, if you want to put 100 pictures into PowerPoint, and each slide should only have 1 picture only, how will you do? Do you insert one by one? It will take at least half an hour or more.
Here I show you a way that can do it in less than 1 minutes!
1. Open PowerPoint.
2. Goto Tools Menu->Macro->Macros
3. Type Macro1
4. Press Create button.
5. Paste the following code:
Sub Macro1()
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog( _
Type:=msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
mleft = InputBox(“x:”)
mtop = InputBox(“y:”)
mwidth = InputBox(“Width (Default=720):”)
mheight = InputBox(“Height (Default=540):”)
If mleft = “” Then mleft = 0
If mtop = “” Then mtop = 0
If mwidth = “” Then mwidth = 720
If mheight = “” Then mheight = 540
n = 1
With dlgOpen
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
ActivePresentation.Slides.Add( _
Index:=n, _
Layout:=ppLayoutBlank).Select
ActiveWindow.Selection.SlideRange.Shapes.AddPicture( _
FileName:=vrtSelectedItem, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=mleft, _
Top:=mtop, _
Width:=mwidth, _
Height:=mheight).Select
n = n + 1
Next vrtSelectedItem
Else
End If
End With
Set dlgOpen = Nothing
End Sub
6. Return to PowerPoint.
7. Goto Tools Menu->Macro->Macros
8. Select Macro1 and press Run button.
9. Input the position of the picture, coordinate x
(Press Enter without typing anything will set x=0)
10. Input the position of the picture, coordinate y
(Press Enter without typing anything will set y=0)
11. Input width of the picture
(Press Enter without typing anything will set width=720)
12. Input height of the picture
(Press Enter without typing anything will set height=540)
13. Select the multiple files you want to insert and press OK button.
14. Done!

No comments:

Post a Comment