如果您大量使用图形,那么您可能已经很熟悉“缩略图”一词。这些是图形的较小版本,打印在一页上,使您可以对所有图形进行“鸟瞰”。许多图形程序和桌面发布程序都包含缩略图功能,可让您自动打印概述。不幸的是,Word不包括此功能,但是您可以使用宏添加这样的功能。以下VBA宏从单个目录的内容创建了一组缩略图:

Sub Thumbnails()

Dim Directory As String    Dim FType As String    Dim FName As String    Dim ColCount As Integer, J As Integer

Directory = "d:\temp"

FType = "*.jpg"



With Application.FileSearch       .FileName = FType       .LookIn = Directory       .Execute       If .FoundFiles.Count > 0 Then          Documents.Add          ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, _              NumColumns:=5          Selection.Tables(1).Select          Selection.Cells.HeightRule = wdRowHeightAuto          With Selection.Rows             .Alignment = wdAlignRowCenter             .AllowBreakAcrossPages = False             .SetLeftIndent LeftIndent:=InchesToPoints(0), RulerStyle:= _                 wdAdjustNone          End With          Selection.HomeKey Unit:=wdLine          ColCount = 1       End If

For J = 1 To .FoundFiles.Count          FName = .FoundFiles(J)

Selection.InlineShapes.AddPicture FileName:=FName, _             LinkToFile:=False, SaveWithDocument:=True          Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter          Selection.TypeParagraph          With Selection.Font             .Name = "Arial"

.Size = 10             .Bold = True          End With          Selection.TypeText Text:=Mid$(FName, Len(Directory) + 2)

Selection.MoveRight Unit:=wdCharacter, Count:=1          ColCount = ColCount + 1          If ColCount = 6 Then             If J <> .FoundFiles.Count Then                Selection.InsertRows 1                Selection.EndKey Unit:=wdLine                Selection.MoveRight Unit:=wdCharacter, Count:=1                Selection.InsertRows 1                Selection.HomeKey Unit:=wdLine                ColCount = 1             End If          End If       Next J    End With End Sub

在此宏中,您需要做的就是更改指定Directory变量的行,以反映存储图形的目录。您也可以通过更改FType的分配来更改图形文件的规范(当前已设置为返回目录中的所有JPG文件)。当您运行此宏时,将创建一个新文档,并且该宏开始构建具有五列的表格,但是打印图形需要许多行。该宏将在一张纸上打印大约40张左右的缩略图,具体取决于您在默认模板中使用的设置。

有一个使用此宏的警告-您应该意识到您的文档大小将非常非常快地增长。虽然在文档中以小(缩略图)尺寸显示图形,但在后台,图形仍保持其完整尺寸。如果要处理的图形很多,那么文档的大小可能会变得很笨拙,并且系统的响应时间可能会非常缓慢。

注意:

如果您想知道如何使用此页面(或_WordTips_网站上的任何其他页面)中描述的宏,我准备了一个包含有用信息的特殊页面。

_WordTips_是您进行经济有效的Microsoft Word培训的来源。

(Microsoft Word是世界上最流行的文字处理软件。)本技巧(116)适用于Microsoft Word 97、2000、2002和2003。您可以为Word(Word 2007)的功能区界面找到此技巧的版本。和更高版本)在这里: