|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
建议你将你的插入图片的方法附上,人家给你修改就行了
不然就参考下面的代码吧:
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 '在所有选取项目中循环
myname = CreateObject("Scripting.FileSystemObject").GetFileName(vrtselecteditem) '取文件名
ActivePresentation.Slides(i).Select
With ActiveWindow.Selection.SlideRange
.FollowMasterBackground = msoFalse
.Background.Fill.UserPicture vrtselecteditem
End With
ActivePresentation.Slides(i).Shapes("Rectangle 2").TextFrame.TextRange = myname
ActivePresentation.Slides(i).Shapes("Rectangle 2").TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignLeft
i = i + 1
Next vrtselecteditem
End If
End With
End Sub
|
|