Professional Documents
Culture Documents
Chris Sistrom1
Janice Honeyman-Buck
Once activated, the macro requests a directory location from the user. It then searches
through the entire directory and obtains the
name the files. Each file is tested to determine
if it contains an image in one of five common
formats, using the three-letter file extension as
its criterion. The five formats include tagged
image file format (.tif), PC paintbrush (.pcx),
bit-mapped graphics format (.bmp), .gif, and
.jpg. If a file has one of these extensions, the
image it contains is placed on a new slide and
added to the presentation.
Before moving to the next file, the program
code centers and sizes the image to make it as
large as possible and still fit on the slide. Large
images are scaled down and small images are
scaled up as needed. PowerPoint stores variables representing the width, height, and absolute position for all shapes (including images)
1591
We have included the entire macro as Appendix I of this article. To keep it as compact
as possible, we have removed comment lines
and show only the program itself. To obtain an
electronic copy of the code, go to the AJR web
site and look up the full text of this article.
Scroll down to Appendix I and copy the text
that appears between the dashed lines. Do this
by highlighting the text with your mouse and
clicking Edit > Copy. Next, open Microsoft
PowerPoint and select Tools > Macro >
Macros. In the top of the resulting dialogue
box, type the name of the macro (Fig. 1). We
used the name Getpix. Then click on Create and another window will open (Fig. 2).
This is the Visual Basic Editor. You should see
the following text in the editing window:
Once the macro has been created in a PowerPoint presentation file, using it is fairly simple. Select Tools > Macro > Macros, and
highlight the name of the macro (e.g., Getpix
as in Fig. 3). After the Run button is clicked,
the macro activates and displays a dialogue
box that asks for the location of the directory
containing the images to be imported. Type the
Sub Getpix()
Macro created mm/dd/yyyy by xxx zzzz
End Sub,
where mm/dd/yyyy is the current date and xxx
zzzz is the users name. If a different name for
the macro was used, it will show up in the first
line instead of Getpix. The macro text (cop-
1592
Computers in Radiology
preferences for slide background and text properties. To start a new working presentation, simply open Blank.ppt and run the macro. Before
importing the images, select File > Save As and
specify a new location and name for your presentation. After you click Save, the file name
at the top of the PowerPoint window will change
to reflect the newly chosen name. The blank presentation will remain unchanged and ready for
the next session.
Presentations can be edited to add text
slides between image slides.
Alternate Solutions
In his article titled Getting Images into PowerPoint, Schreibman [12] briefly notes an enhancement for PowerPoint 2000 that is
available from Microsoft. We accessed the
Web site listed in the article text [14] and
downloaded and installed the program (a
photo album add-in for PowerPoint). We used
the software to import the same set of images
we had previously used to test our macro. The
Fit To Slide option was chosen. The resulting PowerPoint presentation was identical to
one created by our macro in every respect.
Readers are encouraged to experiment with the
Microsoft photo album solution. It has a
graphic interface to browse for image files, allows preview of images, and permits selection
of individual images. However, the photo album addin is specific to the Office 2000 version of PowerPoint. Also, the photo album
Fig. 7.Window displayed after clicking on Edit in PowerPoint (Microsoft) macro dialogue box (Fig. 3). To remove code from current presentation, highlight line called Module1 (arrows), right click with mouse,
and select Remove Module1 from resulting pick list. Answer No to
subsequent dialogue box that offers to save module.
1593
Troubleshooting
1594
Limitations
Our program lacks the ability to add multiple images to a single slide. This feature is not
needed for most purposes. In fact, crowding
multiple images onto one slide may make it
much harder for the audience to see the radiologic findings. Some may believe that putting
multiple images on each slide would reduce
the file size of the resulting presentation. This
is not the case because imported images are
kept in their entirety with scaling tags that are
added to cause them to be displayed as specified. We find it preferable to make the points
about cases and findings in our text slides and
then illustrate the points with full-sized images
augmented with annotations such as arrows.
Multiple images can be placed on a single
slide during the editing of the presentation content after the images have been imported. The
macro code can also be modified to scale images
Computers in Radiology
to one half or one quarter the size of a slide,
which would make it easy to show several images at once. One of the reasons that we are including the full code of the macro is to encourage
readers to modify it to suit their individual needs.
The method of specifying the image input directory is rudimentary and does not use the
graphic file selection methods available in Windows. The user must accurately type the complete path to the image file directory. Also, we
have not provided an option to preview or select
individual images for the import directory.
These features could have been written into our
macro. However, the code would have been
much longer, more complex, and version-specific. We decided to keep the program simple to
reduce the possibility of errors. More functionality requires additional customization of the
PowerPoint installation. Users may already face
challenges in getting the existing code to work
properly on their particular computers.
Conclusion
AJR 2002;179:14111413
5. Taylor GA. Removal of dust and scratches from
electronic image files. AJR 2003;180:15331536
6. Taylor GA. Sharpening the image. AJR 2003;
181:4345
7. Taylor GA. Color correction and automating repetitive tasks. AJR 2003;181:383386
8. Taylor GA. Improving image contrast. AJR 2003;
180:329331
9. Daffner RH. On improvement of scientific presentations: using PowerPoint. AJR 2003;181:4749
10. Dreyer KJ. Using Microsoft PowerPoint for electronic presentations. RadioGraphics 2001;21:
13181321
11. Schreibman KL. Hello, and two great tricks. AJR
2001;177:10171018
12. Schreibman KL. Getting images into PowerPoint. AJR 2001;177:12711272
13. Willing SJ. Getting images into PowerPoint. AJR
2002;179:533534
14. Microsoft Download Center. Microsoft Web site.
Available at: http://office.microsoft.com/downloads/2000/album.aspx. Accessed March 19, 2004
15. Frank MS, Schultz T, Dreyer K. Integrating digital
teaching-file systems with off-the-shelf presentation software to facilitate speaker-led conferences. J
Digit Imaging 2001;14[suppl 1]:98101
16. Authors Web site. Avialable at: http://
xray.ufl.edu/sistrom
1595
Here is the exact text of the macro. Highlight all the text below this paragraph, copy, and paste into the PowerPoint Macro > Create window (Fig. 1).
Dim File_Cnt, Sld_Cnt, Sld_Pos As Long
Dim Source_Dir, File_Name, Path_Complete, Ext_3, Ext_4 As String
Dim sldNewSlide As Slide
Dim shpPicture As Shape
Dim tmpWidth, tmpHeight, W_H_pic, W_H_sld, lngSldHeight, lngSldWidth As Double
File_Cnt = 0
Sld_Cnt = 0
Source_Dir = InputBox(Location of images, End with / (: for Macintosh), Image Directory)
If Len(Source_Dir) = 0 Or IsNull(Source_Dir) Then GoTo No_Input_Exit
On Error GoTo No_Input_Exit
File_Name = Dir(Source_Dir, vbNormal)
While Len(File_Name) <> 0
File_Cnt = File_Cnt + 1
Ext_3 = UCase(Right(File_Name, 3))
Ext_4 = UCase(Right(File_Name, 4))
If Ext_3 = TIF Or Ext_3 = GIF Or Ext_3 = JPG _
Or Ext_4 = JPEG Or Ext_3 = PCX Or Ext_3 = BMP Then
Sld_Cnt = Sld_Cnt + 1
Path_Complete = Source_Dir & File_Name
Sld_Pos = ActivePresentation.Slides.Count
Set sldNewSlide = ActivePresentation.Slides.Add(Index:=Sld_Pos + 1, _
Layout:=ppLayoutBlank)
Set shpPicture = sldNewSlide.Shapes.AddPicture(FileName:=Path_Complete, _
LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
Left:=0, Top:=0, Width:=100, Height:=100)
shpPicture.LockAspectRatio = True
shpPicture.ScaleHeight 1#, msoCTrue
shpPicture.ScaleWidth 1#, msoCTrue
lngSldWidth = ActivePresentation.PageSetup.SlideWidth
lngSldHeight = ActivePresentation.PageSetup.SlideHeight
tmpWidth = shpPicture.Width
tmpHeight = shpPicture.Height
W_H_pic = tmpWidth / tmpHeight
W_H_sld = lngSldWidth / lngSldHeight
If W_H_pic >= W_H_sld Then
shpPicture.Width = lngSldWidth
Else
shpPicture.Height = lngSldHeight
End If
tmpWidth = shpPicture.Width
tmpHeight = shpPicture.Height
shpPicture.Top = (lngSldHeight - tmpHeight) / 2
shpPicture.Left = (lngSldWidth - tmpWidth) / 2
End If
File_Name = Dir()
Wend
No_Input_Exit:
MsgBox Input Directory= & Source_Dir & Chr(13) & Chr(10) & _
Total Files= & File_Cnt & Slides Added= & Sld_Cnt, vbOKOnly, Results
1596