|
Sub InsertPic()
Dim i As Integer
Dim MyDialog As FileDialog, vrtSelectdeItem As Variant
On Error Resume Next
'定义一个文件选取对话框
Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)
With MyDialog
.Filters.Clear '清除所有文件筛选器中的项目
.Filters.Add "所有 WORD 文件", "*.jpg;*.bmp", 1 '增加筛选器的项目为所有jpg、bmp等文件
.AllowMultiSelect = True '允许多项选择
If .Show = -1 Then
If ActivePresentation.Slides.Count < .SelectedItems.Count Then
For i = 1 To .SelectedItems.Count - ActivePresentation.Slides.Count
ActivePresentation.Slides.Add(Index:=ActivePresentation.Slides.Count, Layout:=ppLayoutText).Select
Next i
End If
i = 1
For Each vrtselecteditem In .SelectedItems '在所有选取项目中循环
ActivePresentation.Slides(i).Select
With ActiveWindow.Selection.SlideRange
.FollowMasterBackground = msoFalse
.Background.Fill.UserPicture vrtselecteditem
End With
i = i + 1
Next vrtselecteditem
End If
End With
End Sub |
|