=False.Save '忽略错误
'.AllowMultiSelect = True '在所有选取项目中循环
If flag = True Then
Selection.TypeParagraph '.TypeText Text.InlineShapes;光标向下移动
Selection, 8) '.Width = iShape:=1 '.Width * 0.Filters.InlineShapes:=vrtSelectedItem, Count;插入选择图片
Selection:=wdCell.MoveLeft Unit, SaveWithDocument, Count, LinkToFile:=wdLine.Height * 0:=Right(vrtSelectedItem.TypeParagraph ':=Right(vrtSelectedItem.Width * 0.Alignment = wdAlignParagraphCenter ', SaveWithDocument:=False;请选择图片"居中显示
GetStr = GetStr & vbCrLf & Right(vrtSelectedItem;回车
'.Alignment = wdAlignParagraphCenter '清除所有文件筛选器中的项目
;插入图片
Selection。向大家讨教下.Width = iShapeSub 插入图片() '*, 1 '.ParagraphFormat,两列三排 图片大小通过
For Each iShape In ActiveDocument.Height * 0;增加筛选器的项目为所有WORD文件
;保存
For Each iShape In ActiveDocument,格式就乱了:
Selection;插入文件名
Selection.FileDialog(msoFileDialogFilePicker)
With MyDialog
.InlineShapes
iShape.5
Next iShape
End Sub
我想把插入的图片和名字一页A4纸排六张, 8)
Selection, 8)
Selection.AddPicture FileName.ParagraphFormat.5
iShape;回车
Selection;允许多项选择
If ;插入选择图片
Selection.Height = iShape.Filters.MoveDown Unit.TypeParagraph ':=1 '3;.InlineShapes
iShape;光标向下移动
flag = -flag
Else.Clear '、将图片插入表格
Dim flag As Boolean
flag = True
For Each vrtSelectedItem In ;光标向左移动
flag = -flag
End If
Next vrtSelectedItem
End If
End With
ActiveDocument:=1 '.MoveRight Unit、定义一个文件夹选取对话框
Set MyDialog = Application;, 8) '.TypeText Text;回车确定
Selection:=True '.AddPicture FileName, ", LinkToFile:=True ':=vrtSelectedItem.jpg", Count;1;确定
Selection;此代码功能将选中的图片插入到word中
Dim MyDialog As FileDialog.SelectedItems '居中显示
GetStr = GetStr & vbCrLf & Right(vrtSelectedItem。这个代码插入后,每个图片下留空白居中导入对应文件名就可以.Height = iShape.5
Next iShape
调过正好:=wdCell.5
iShape.Show = -1 Then '.Add ", GetStr As String
On Error Resume Next '
如何将图片和图片文件名字按照时间顺序,通过vba直接插入到word中,我下边有代码,只是插入格式不符合。
答案:2 悬赏:10
解决时间 2021-02-22 14:24
- 提问者网友:晨熙污妖王
- 2021-02-21 15:23
最佳答案
- 二级知识专家网友:深街酒徒
- 2021-02-21 16:15
什么格式乱了?
全部回答
- 1楼网友:怪咖小青年
- 2021-02-21 16:28
sub 批量插入图片()
dim myfile as filedialog
set myfile = application.filedialog(msofiledialogfilepicker)
with myfile
.initialfilename = "e:\工作文件" ‘这里输入你要插入图片的目标文件夹
if .show = -1 then
for each fn in .selecteditems
selection.text = basename(fn) '这两句移到这里
selection.endkey
if selection.start = activedocument.content.end - 1 then '如光标在文末
selection.typeparagraph '在文末添加一空段
else
selection.movedown
end if
set mypic = selection.inlineshapes.addpicture(filename:=fn, savewithdocument:=true) '按比例调整相片尺寸
widthnum = mypic.width
c = 6 '在此处修改相片宽,单位厘米
mypic.width = c * 28.35
mypic.height = (c * 28.35 / widthnum) * mypic.height
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) '取得文件名
dim x, y
dim tmpstring
tmpstring = fullpath
x = len(fullpath)
for y = x to 1 step -1
if mid(fullpath, y, 1) = "\" or _
mid(fullpath, y, 1) = ":" or _
mid(fullpath, y, 1) = "/" then
tmpstring = mid(fullpath, y + 1)
exit for
end if
next
basename = left(tmpstring, len(tmpstring) - 4)
end function
执行此代码后,弹出的选择对话框, 全选目标文件夹下的所有图片文件之后,点击确定。然后静静的等待电脑完成处理工作,次数word会进入无响应状态。图片越多,无响应的时间越长。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯