word文档批量插入图片及其文件名-宏脚本处理
Sub PicWithCaption()
Dim xFileDialog As FileDialog
Dim xPath, xFile As Variant
On Error Resume Next
Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFileDialog.Show = -1 Then
xPath = xFileDialog.SelectedItems.Item(1)
If xPath <> "" Then
xFile = Dir(xPath & "\*.*")
Do While xFile <> ""
If UCase(Right(xFile, 3)) = "PNG" Or _
UCase(Right(xFile, 3)) = "TIF" Or _
UCase(Right(xFile, 3)) = "JPG" Or _
UCase(Right(xFile, 3)) = "GIF" Or _
UCase(Right(xFile, 3)) = "BMP" Then
With Selection
.InlineShapes.AddPicture xPath & "\" & xFile, False, True
.InsertAfter vbCrLf
.MoveDown wdLine
.Text = xPath & "\" & xFile & Chr(10)
.MoveDown wdLine
.MoveDown wdLine
End With
End If
xFile = Dir()
Loop
End If
End If
End Sub
本文介绍了一个使用VBA宏脚本的方法,该方法能够帮助用户在Word文档中批量插入特定类型的图片(如PNG、TIF、JPG等),并在每张图片下方自动添加对应的文件路径作为说明。
1万+

被折叠的 条评论
为什么被折叠?



