
Tips.Net > WordTips Home > Macros > VBA Examples > Printing Graphic Thumbnails
Summary: If you use a lot of graphics in your Word documents, then you may want to help manage those graphics by printing small “thumbnails” of all the graphics in a folder. This tip includes a macro that will print thumbnail sheets that are great for just that purpose. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
If you work with graphics quite a bit, you are probably already familiar with the term "thumbnails." These are smaller versions of your graphics, printed on a single page, that allow you to get a "birds-eye view" of all your graphics. Many graphics programs and desktop publishing programs include a thumbnail feature that allows you to automatically print your overview. Unfortunately, Word does not include this feature, but you can add such a feature with a macro. The following VBA macro creates a set of thumbnail images from the contents of a single directory:
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 = "*.pcx"
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
In this macro, all you need to do is change the line specifying the Directory variable to reflect the directory in which your graphics are stored. You can also change the graphic file specification by changing the assignment of FType (currently it is set to return all PCX files in the directory). When you run this macro, a new document is created and the macro starts building a table with five columns and however many rows are necessary to print your graphics. The macro will print about 40 or so thumbnails on a piece of paper, depending on the settings you use in your default template.
Tip #116 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful "wildcard searches" available in Word.
Check out WordTips: Find and Replace today!
Learn to use styles and you discover the real power behind Word. Fast, easy, consistent document formatting and updating is within your grasp. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips