- 精华
- 活跃值
-
- 积分
- 151
- 违规
-
- 印币
-
- 鲜花值
-
- 在线时间
- 小时
累计签到:79 天 连续签到:1 天
|
就是有多张图片 想要处理成一张图片加文件名一页的时候。。好使
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 |
|