用下列代码(版主教我的)插入图片,插入的图片要求分别为嵌入型或紧密型,应如何改动?
自己水平太低,老麻烦别人,自觉很不好意思——没办法。
Sub 紧密型图片()
Options.DefaultFilePath(Path:=wdPicturesPath) = "D:\图片\紧密型图片\"
Dialogs(wdDialogInsertPicture).Show
End Sub
————————————————————————————————
Sub ExampleToInsertPng()
Dim MyDialog As FileDialog, vrtSelectedItem As Variant, MyRange AsRange
On Error Resume Next '忽略错误
'设置查找文件时 Word 所指向的文件夹
Application.ScreenUpdating = False
Application.ChangeFileOpenDirectory "D:\图片\嵌入型图片"
'定义一个文件夹选取对话框
Set MyDialog = Application.FileDialog(msoFileDialogFilePicker)
With MyDialog
.Filters.Clear '清除所有文件筛选器中的项目
.Filters.Add "PNG文件", "*.png", 1 '增加筛选器的项目为所有WORD文件
.AllowMultiSelect = True '允许多项选择
If .Show = -1 Then '确定
With ActiveDocument
For Each vrtSelectedItem In MyDialog.SelectedItems '在所有选取项目中循环
Set MyRange = .Range(.Content.End - 1, .Content.End - 1)
.Shapes.AddPicture FileName:=vrtSelectedItem, Anchor:=MyRange
.Content.InsertAfter Chr(13)
Next vrtSelectedItem
End With
End If
End With
Application.ScreenUpdating = True
End Sub |