|
- Sub 图片批插() Rem ************************************************************ Rem 作 者: 张斌 Rem 功 能: 将扫描业绩图片文件批量插入word文件中 Rem 备 注: 需要改进 Rem 反馈邮箱:gogozb@163.com Rem 业务联系QQ:1065886598 Rem 帖子:http://club.excelhome.net/forum.php?mod=guide&view=my Rem ************************************************************ Rem VBA知识点: Application.ScreenUpdating = False Dim ph$, d As Object, d1 As Object With Application.FileDialog(msoFileDialogFolderPicker) If .Show = -1 Then ph = .SelectedItems(1) Else Exit Sub End If End With ThisDocument.Content.Delete With CreateObject("scripting.filesystemobject") Fn = .GetFileName(ph) With Application.Selection .InsertAfter Fn .Style = ActiveDocument.Styles("标题 1") .EndKey Unit:=wdStory '光标定位至文末 .TypeParagraph '插入一个新的空段落 End With For Each d In .getfolder(ph).subfolders Fs = .GetFileName(d) With Application.Selection .InsertAfter Fs .Style = ActiveDocument.Styles("标题 2") .EndKey Unit:=wdStory '光标定位至文末 .TypeParagraph '插入一个新的空段落 End With For Each d1 In d.Files If .GetExtensionName(d1) = "JPG" Or .GetExtensionName(d1) = "png" Or .GetExtensionName(d1) = "jpg" Or .GetExtensionName(d1) = "bmp" Then With Application.Selection .EndKey Unit:=wdStory '光标定位至文末 .InlineShapes.AddPicture FileName:=d1.Path .Style = ActiveDocument.Styles("正文") End With End If Next d1 Selection.TypeParagraph Next d End With Application.ScreenUpdating = True MsgBox "插入完毕!", 48, "提示!" End Sub
复制代码 |
|