怎么把许多图片放到word文档中?

2024-10-31 07:25:32
推荐回答(1个)
回答1:

1、acdsee可以打印缩略图,带文件路径的

2、也可以用如下的word宏

Sub 宏1()
'
'成都豺狼
'
pth = "C:\\My Pictures\\"
'读入文件的路径
fln = Dir(pth & "*.jpg")
'文件类型,没有其它文件,可以只用路径

wdth = ActiveDocument.PageSetup.PageWidth - ActiveDocument.PageSetup.LeftMargin - ActiveDocument.PageSetup.RightMargin
hght = ActiveDocument.PageSetup.PageHeight - ActiveDocument.PageSetup.TopMargin - ActiveDocument.PageSetup.BottomMargin
a = ActiveDocument.Paragraphs.LineSpacing
cnt = 0

Do While Len(fln) > 0

If cnt Mod 6 = 0 Then

Selection.MoveRight Unit:=wdCharacter, Count:=1

Selection.TypeParagraph

'Selection.InsertBreak Type:=wdPageBreak

ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _

4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _

wdAutoFitFixed

Selection.Tables(ActiveDocument.Tables.Count).Select

Selection.SelectCell

Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter

ActiveDocument.Tables(ActiveDocument.Tables.Count).AllowAutoFit = False

ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(3).Select

Selection.Orientation = wdTextOrientationVertical

ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(1).Select

Selection.Orientation = wdTextOrientationVertical

ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(1).Width = wdth * 0.05

ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(2).Width = wdth * 0.45

ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(3).Width = wdth * 0.05

ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(4).Width = wdth * 0.45

ActiveDocument.Tables(ActiveDocument.Tables.Count).Rows.Height = (hght - a - a) * 0.33

tablebili = ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(2).Width / ActiveDocument.Tables(ActiveDocument.Tables.Count).Rows.Height

End If

Selection.TypeText Text:=fln

Selection.MoveRight Unit:=wdCharacter, Count:=1

Selection.InlineShapes.AddPicture FileName:= _

pth & fln, LinkToFile:=False, _

SaveWithDocument:=True

cnt = ActiveDocument.InlineShapes.Count

bili = ActiveDocument.InlineShapes(cnt).Width / ActiveDocument.InlineShapes(cnt).Height

If tablebili > bili Then '控制图形按纵横比例显示,要拉伸就直接用行高列宽

ActiveDocument.InlineShapes(cnt).Height = ActiveDocument.Tables(ActiveDocument.Tables.Count).Rows.Height

ActiveDocument.InlineShapes(cnt).Width = ActiveDocument.InlineShapes(cnt).Height * bili

Else

ActiveDocument.InlineShapes(cnt).Width = ActiveDocument.Tables(ActiveDocument.Tables.Count).Columns(2).Width

ActiveDocument.InlineShapes(cnt).Height = ActiveDocument.InlineShapes(cnt).Width / bili

End If

Selection.MoveRight Unit:=wdCharacter, Count:=1

fln = Dir

DoEvents
Loop
End Sub