word自动多图排版加文件名宏。
就是有多张图片 想要处理成一张图片加文件名一页的时候。。好使Sub 插入图片()
Dim myfile As FileDialog
Z = InputBox("请输入插入图片的宽度:", "厘米单位", 14) * 28.35
Set myfile = Application.FileDialog(msoFileDialogFilePicker)
With myfile
.InitialFileName = "E:\"
If .Show = -1 Then
For Each fn In .SelectedItems
Set mypic = Selection.InlineShapes.AddPicture(FileName:=fn, SaveWithDocument:=True)
pw1 = mypic.Width
ph1 = mypic.Height
mypic.Width = Z
mypic.Height = ph1 * Z / pw1
If Selection.Start = ActiveDocument.Content.End - 1 Then'如光标在文末
Selection.TypeParagraph '在文末添加一空段
Else
Selection.MoveDown
End If
Selection.Text = Basename(fn) '函数取得文件名
Selection.EndKey
If Selection.Start = ActiveDocument.Content.End - 1 Then'如光标在文末
Selection.TypeParagraph '在文末添加一空段
Else
Selection.MoveDown
End If
Next fn
Else
End If
End With
Set myfile = Nothing
End Sub
Function Basename(FullPath) '取得文件名
Basename = Left(CreateObject("Scripting.FileSystemObject").getfile(FullPath).Name, InStr(CreateObject("Scripting.FileSystemObject").getfile(FullPath).Name, ".") - 1)
End Function
图片在这里。。就是这种效果。 居中和字体大小先设计好 还不如直接用其他软件做呢,如CDR 对于特定场合还是用得着的,谢谢楼主的分享 这个还挺实用的,多谢楼主分享
页:
[1]