1. Sub 批量插入图片及标题()
    2. Dim xFileDialog As FileDialog
    3. Dim xPath, xFile As Variant
    4. On Error Resume Next
    5. Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    6. If xFileDialog.Show = -1 Then
    7. xPath = xFileDialog.SelectedItems.Item(1)
    8. If xPath <> "" Then
    9. xFile = Dir(xPath & "\*.*")
    10. Do While xFile <> ""
    11. If UCase(Right(xFile, 3)) = "PNG" Or _
    12. UCase(Right(xFile, 3)) = "TIF" Or _
    13. UCase(Right(xFile, 3)) = "JPG" Or _
    14. UCase(Right(xFile, 3)) = "GIF" Or _
    15. UCase(Right(xFile, 3)) = "BMP" Then
    16. With Selection
    17. .InlineShapes.AddPicture xPath & "\" & xFile, False, True
    18. .InsertAfter vbCrLf
    19. .MoveDown wdLine
    20. .Text = xPath & "\" & xFile & Chr(10)
    21. .MoveDown wdLine
    22. .MoveDown wdLine
    23. End With
    24. End If
    25. xFile = Dir()
    26. Loop
    27. End If
    28. End If
    29. End Sub