?
Solved

Powerpoint - Inserting Many Photos

Posted on 2000-02-11
27
Medium Priority
?
1,257 Views
Last Modified: 2008-03-03
I need help finding a way to make inserting many photos into a powerpoint presentation more efficient.  How would I take a batch of digital images (usually 50 to 300) and put each image on its own slide?  And also at a particular height and width?  Is there a macro available for this?  If not, can you get me started?  I don't know Visual Basic programming, so if there is code involved please help.  It's repetitive, boring and cumbersome (the computer should be doing the work, not me) to do this one picture at a time, there must be a way of taking the whole batch of images and doing a batch entry.  I am not concerned about the titles - those I need to enter one at a time - I am just talking about inserting the photo images, one to a slide, and if possible also getting them to the right size.
0
Comment
Question by:jwilk8284
  • 13
  • 12
  • 2
27 Comments
 

Author Comment

by:jwilk8284
ID: 2587943
Adjusted points to 400
0
 
LVL 13

Expert Comment

by:cri
ID: 2650676
Strange that nobody tackled this one. As you can record the "insert picture from file", it should be feasible to make a loop using VBA.

Therefore:

a) Are you still out there ?

b) Would it be possible to have a
dedicated directory containing only these pictures which will be included ?

c) As it would be my first Powerpoint macro: Is time crucial ?

d) Regarding picture type, directories etc.: What is fixed what must be user input ?
0
 

Author Comment

by:jwilk8284
ID: 2662140
cri,
I've checked now and then.  Glad you responded.  
Yes, I usually put the pictures in a dedicated directory on my local hard drive.  Time is not that crucial in this case.  What I do is insert each jpg picture into its own slide, in a standard template I have set up.  Then, I usually have to re-size each photo manually (click and drag) to fit its slide.  The pictures from the digital camera I use are usually too big, so I bring them down to a height of 6 and a width of 8.  Finally, I add a title.  Not sure if I answered all of your questions.  Let me know if you need anything else.  Thank you.
jwilk8284
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 13

Expert Comment

by:cri
ID: 2663076
Ok I will make a pass at it, but it will take a week or so.

I do not understand your comment "...I checked now and then..." Don't you have e-mail notification, it is below the comment editing window, checked ?

Did you ever record or at least use a macro ? Are you interested in this ? Its fairly easy and I consider it as the entry step to making your life easier by automating your repetitive tasks. I mention it here because if you would record and paste here what you do when importing, I could make a loop and insert the dialog boxes where you could make the necessary input.
0
 

Author Comment

by:jwilk8284
ID: 2664671
cri,

After reading your comment, I checked my profile and found a typo in the e-mail address.  

About recording a macro, I have tried this before once or twice - very inexperienced.  However, I tried to record a macro.  See below.  

Sub InsertPics()
'
' Macro recorded 3/28/00 by Jim Wilkinson
'
    ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="C:\SitePics\002Mvc-416l.jpg", LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=-23, Top:=-17, Width:=768, Height:=576).Select
    With ActiveWindow.Selection.ShapeRange
        .Height = 431.88
        .Width = 575.88
        .Left = 71.88
        .Top = 53.88
    End With
    ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
    ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
    ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=0).Select
    With ActiveWindow.Selection.TextRange
        .Text = "Approaching N-31"
        With .Font
            .Name = "Times New Roman"
            .Size = 28
            .Bold = msoFalse
            .Italic = msoFalse
            .Underline = msoFalse
            .Shadow = msoFalse
            .Emboss = msoFalse
            .BaselineOffset = 0
            .AutoRotateNumbers = msoTrue
            .Color.SchemeColor = ppTitle
        End With
    End With
    ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=8, Layout:=ppLayoutTitleOnly).SlideIndex
End Sub

When I get back from shooting pictures, I upload all images from the digital camera into a folder called "C:\SitePics".  (note: eventually, I move the images from this folder to accomodate the next batch of images).  The file names are generated automatically by the digital camera, an example is "001Mvc-415l.jpg".  I always check the "Link to File" and "Save with Document" boxes when inserting.  Then I re-size the image.  Then add the title in the Title Text Box.  After that, add a new slide and repeat the process with the next image - by next image, I mean the next one in chronological order.  That doesn't show up in the above macro because I'm not sure how to make that happen.

jwilk8284  
0
 
LVL 13

Expert Comment

by:cri
ID: 2670988
I will post the first version in about 8-10 hours. Should you see this comment first: Is the caption writen in the Title of a "Title Only" layout or is it a regular textbox ?

Reason I am asking is that I am battling somewhat with the %*"&%! lame brained way of Microsoft to continuously assign numbers to shapes per Powerpoint start. In Excel I could assign name to them, but I am not there yet. Probably I will have to send you a raw cut version to determine the room for improvement.  
0
 
LVL 13

Expert Comment

by:cri
ID: 2670995
not send, post
0
 
LVL 13

Expert Comment

by:cri
ID: 2672459
Paste everything below the demarcation line into the same module where you have the recorded macro. Make sure you have some pics in the same directory.

More after the break, meaning feedback from you, especially regarding your needs/wishes regarding room for improvement, see header macro (with a 400 pointer you deserve it)


'xxxxDemarcationUsedToInforceFrameWidthExpertsExchange**xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Sub InsertAllPics_v1()

' Inserts all files into a Powerpoint presentation in the _same_ directory
'
' Room for improvement:
'  - General finetuning as size and location of title frame
'  - Is first inserted picture = last slide acceptable ? Considerably easier to handle
'  - Would separate directories for Powerpoint and pictures be an advantage ?
'  - Include filename in footer in fine print ?
'  - Input dialog to edit and insert picture title for each slide ?
'  - Delete last slide as empty

   'Initialisation
   
   ' Declare all variables
   Dim MyPics As String, SlideNumber As Integer
   Dim InpTxt As String, InpPath As String
     
   ' Define input dialog text
   InpTxt = "Will import all indicated pictures. Accept default or modify:"
   ' Get user confirmation/modification of picture directory/extension
   InpPath = InputBox(InpTxt, "InsertAllPics_v1", "C:\SitePics\*.jpg")
   
   ' Returns _first_ file *.jpg found in indicated directory
   MyPics = Dir(InpPath)
   
   ' Ensure slideview as macro can not run in slide sorter view
   ActiveWindow.ViewType = ppViewSlide
     
   ' Start the importing
   Do While MyPics <> ""
           
      ' Add new slide at the _beginning_ of the presentation
      ' Avoids messing with counter
      ActivePresentation.Slides.Add 1, ppLayoutTitleOnly
      'and go there
      ActiveWindow.View.GotoSlide Index:=1
           
      ' Add pic with values posted in E-E (which overlaps with tile)
      ActivePresentation.Slides(1).Shapes.AddPicture(FileName:=MyPics, _
             LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _
             Left:=72, Top:=54, Width:=576, Height:=432).Select
           
      ' If scaling not needed, delete this section
      With ActiveWindow.Selection.ShapeRange
         .ScaleWidth 0.85, msoFalse, msoScaleFromBottomRight
         .ScaleHeight 0.85, msoFalse, msoScaleFromBottomRight
         .IncrementLeft -43 ' calculated as -(1 - 0.85)*572/2
         .IncrementTop 20
      End With
         
      ' Using Titles, a textbox might be better solution
      With ActivePresentation.Slides(1).Shapes.Title.TextFrame.TextRange
         .Characters(Start:=1, Length:=0).Select
         .Text = MyPics 'Filename as placeholder for later editing
             With .Font
                .Name = "Times New Roman"
                .Size = 28
                .Bold = msoFalse
                .Italic = msoFalse
                .Underline = msoFalse
                .Shadow = msoFalse
                .Emboss = msoFalse
                .BaselineOffset = 0
                .AutoRotateNumbers = msoTrue
                .Color.SchemeColor = ppTitle
             End With
      End With
     
      'Call Dir again w/o arguments to return next (DOS) indicated file
      MyPics = Dir
   Loop
     
   ' For visual check and eventual sorting
   ActiveWindow.ViewType = ppViewSlideSorter

End Sub
0
 

Author Comment

by:jwilk8284
ID: 2673597
cri,

The macro bogged down early. So I didn't get to fully evaluate your solution.  

The powerpoint presentation I ran is in the "D:\ENGR_RVWS" folder.  The dialog box for the directory came up fine - I pressed the OK button to accept the default directory "C:\SitePics\*jpg" since that is where I keep my photos.  Then a Microsoft Visual Basic box appeared with the following message: "Run-time error' -2147188160 (80048240)': Shapes (unknown member): Out of memory error."  

To answer your earlier question - yes, the caption is written in the Title of a "Title Only" layout.

Other questions you have:

"Is first inserted picture = last slide acceptable ? Considerably easier to handle"  As I stated before, chronological order is best.  If you are saying reverse order is much easier - that would be fine if there was a quick way to re-sort but I don't see that Powerpoint provides a way to do that.  

"Would separate directories for Powerpoint and pictures be an advantage ?"  Not sure what you mean, I thought that's what we were doing anyway.  If I provide the following information maybe your question will be answered.  On my machine, the Powerpoint application is in C:\MSOffice\Office folder, photos are in C:\SitePics folder, and each presentation has its own project folder on the D:\ drive (sub-folders to the "D:\ENGR_RVWS" folder).

"Include filename in footer in fine print ? "  Not necessary.

"Input dialog to edit and insert picture title for each slide ? "  That's a great idea, I would appreciate that.





0
 
LVL 13

Expert Comment

by:cri
ID: 2674340
For testing purposes please put your Powerpoint file in the same directory as a _test_ set of pictures, see header of macro. Reason I did not made it yet is that (presently) I think there will be a need to have 2 input dialogs: One for the directory and one for the file extension. Whereas you could say skip the extension (as _always_ *.jpg) I must point out that you can only have the pictures you want to import in the directory. Either you move the previous out or I give you the feature to address another directory (which should exist, I must draw the line somewhere...)

As for the title edit dialog: I must think this over, perhaps I can not get the view refresh working and/or the speed of the current solution which would allow this feature is too low. Explanation: I am toying in formatting and sizing in one go, using ranges, time to think object oriented instead of procedurally. But I will only do this if it is too slow, I am not this kind of purist. Please inform how long it takes to import a medium to large batch.
0
 
LVL 13

Expert Comment

by:cri
ID: 2674379
Regarding you moving the pictures out of c:\sitepics

a) Did you never had any troubles when editing/modifying the presentation afterwards  ? Reason is that you, besides embeding, link the pictures, i.e. the reference will not be correct after the move.

b) Why do you embed _and_ link ? Do you distribute the presentation and still want to keep the "original" pictures ?
0
 

Author Comment

by:jwilk8284
ID: 2674551
cri,

OK, the photos imported into the presentation, in reverse order, with the photo's filename as the title.  That's a good start!

In my template, there are four introductory slides. If you can make the insertions begin on slide 5, that would be great.  If not, I can manually move those four introductory slides back to the beginning manually.

The photos came in at a height of 5.1 inches and a width of 6.8 inches.  Will you make that 6.0x8.0?

The photos came in at 1.6 inches horizontal and 1.93 inches vertical relative to the top left corner.  Will you make that 1.08 inches horizontal and 0.67 inches vertical?

I hope you can solve the problem with respect to order.  Your current macro is better than what I have now, but I wouldn't look forward to manually putting the slides in the correct order.  It would negate some of the time gained by the automatic insertion of the photos.

The dialog box that comes up has "C:\SitePics\*jpg"  as the default.  Is that the only directory the macro will work with?  I tried to put the presentation file into a different directory with a bunch of photos, and change the directory name manually in the dialog box (BTW, if it is possible to use a different directory, will you build in a file find box? - it's a pain to type out long path names manually) and it didn't seem to work.  

Regarding input of the titles, I have thought about that further and think that this can be done manually, outside of the macro.  Really, the big thing is to get all the photos situated in the right place, the right size, and in order.  I really loved seeing all those photos pop into the presentation automatically, so quickly!  What a timesaver.  

It looks like you are not far away from a final solution.  What you have right now, is fine, with the exception of the order and the few minor items listed above.  Will you please look at those improvements?

0
 

Author Comment

by:jwilk8284
ID: 2674564
cri,

Perhaps I don't understand the Embed and Link concepts.  What I am after is this.  I would like to distribute the presentation after it is done, by placing it out on our LAN server.  I want it to be a standalone file, and not have to put the photos out on the server along with the presentation file.  Is it unnecessary to Link?
0
 

Author Comment

by:jwilk8284
ID: 2674568
cri,

Perhaps I don't understand the Embed and Link concepts.  What I am after is this.  I would like to distribute the presentation after it is done, by placing it out on our LAN server.  I want it to be a standalone file, and not have to put the photos out on the server along with the presentation file.  Is it unnecessary to Link?
0
 
LVL 13

Expert Comment

by:cri
ID: 2674915
I will tackle this to the end, but it can take up to a week, I am quite busy and this is my first Powerpoint macro.

Now for the details:

a) I probably will be able to fix the order.

b) Starting from slide 5 should be feasible. Is it correct that you have a template for this ?

c) I scaled it because I have A4 paper and the picture overlapped with my _default_ Title. What paper size and margins do you have in your presentation ? Try with inactivating the scaling section (precede each line with a ').

d) Strange that it did not work with another directory. Did you start the presentation there or did you make a save as only ? Will keep an eye on this. You sure you put ..\*.jpg and not ..\*jpg as you wrote ?

e) Passing return from File Open dialog to my input box...Uhhh... Will see, but I do not promise anything.

Picture the link as a tight "rope" to an external file and the embed as tucking it into the presentation. Linking is good if the files will be updated/revised as this happens with reports etc., but to distribute they are a pain. If you are sure your pictures are not going to be edited, embeding is what you need. Whether you keep the pictures is up to you, I rembember that *.jpg inserted into an Office application are converted to *.emf (or whatever) and get much bigger.
0
 

Author Comment

by:jwilk8284
ID: 2675116
cri,

one week - fine

a) great.

b) yes, I have a template.

c) I will check this when I get back to work on Monday.  What do you mean by "Try with inactivating the scaling section (precede each line with a ')?"

d) I will try this again, on Monday, to be sure, and will tell you exactly what it is doing.

e) that is fine.

Thanks for the explanation on "link" and "embed".

I'll get back to you on Monday.  
0
 
LVL 13

Expert Comment

by:cri
ID: 2676369
Regarding c) You can inactivate code by preceding a ' before each line, the VBA interpreter will treat as comment and it will be in red in the VBA editor. Is better than to delete, perhaps we will need it. Afterwards it should look like this:

' If scaling not needed, delete this section
      ' With ActiveWindow.Selection.ShapeRange
        ' .ScaleWidth 0.85, msoFalse, msoScaleFromBottomRight
        ' .ScaleHeight 0.85, msoFalse, msoScaleFromBottomRight
        ' .IncrementLeft -43 ' calculated as -(1 - 0.85)*572/2
        ' .IncrementTop 20
    '  End With
           
Additionally: As a.m. what paper size and margins to you have ?      
0
 

Author Comment

by:jwilk8284
ID: 2680923
cri,

In "Page Setup", slides are sized for "On Screen Show", width =10 inches, height = 7.5 inches, Landscape.

0
 
LVL 13

Expert Comment

by:cri
ID: 2681741
Thanks, I did not forget your question.
0
 

Author Comment

by:jwilk8284
ID: 2687500
cri,

Followup to earlier discussion:

c) inactivated the scaling section, and the photos came in much better this time.  Good suggestion.

d) tried putting the presentation file and photos in a different directory, ran the macro and it brought the photos in, so disregard previous comment and I apologize for any confusion.

 
0
 
LVL 13

Accepted Solution

by:
cri earned 1600 total points
ID: 2694925
Here the second version:

a) Strange you state the previous version imported ok from a different dir, on my machine the macro crashes, therefore I separated the input.

b) The size of the picture can be corrected directly without fussing with the scale

c) I have built in some additional functionality, see comments.

d) As far I can see, for the File Open dialog you either must buy a MacIntosh or I would have to built a user form, which is above my current know-how and more difficult for you to implement.


Sub InsertAllPics_v2()

' Inserts all files into a Powerpoint presentation from a given directory
' Functionality see local comments

   ' Initialisation
   
   ' Declare all variables
   Dim MacroName As String, MyPics As String, SlideNumber As Integer
   Dim DlgPathTxt As String, DlgPathRet As String, DlgFileTxt As String, DlgFileRet As String
   Dim DlgModeTxt As String, DlgModeRet As String, DlgTitleRet As String
   
   ' Define input dialog title
   MacroName = "InsertAllPics_v2"
   
   ' Get path. Default as indicated, inputing 'ppt' changes to current dir
   DlgPathTxt = "Accept or  modify path of picture directory " & Chr(13) _
                & "(for current Powerpoint dir give ' ppt ' as input)"
   DlgPathRet = InputBox(DlgPathTxt, MacroName & ": Step 1 of 3", "C:\SitePics")
   If DlgPathRet = "ppt" Then
      DlgPathRet = CurDir
      MsgBox ("Will import pictures of current directory: " & DlgPathRet)
   End If
   
   ' Get file type, if none is given macro is aborted
   DlgFileTxt = "Accept or modify file type:" & Chr(13) _
                & "(multi ' * ' and single ' ? ' character wildcards supported)"
   DlgFileRet = InputBox(DlgFileTxt, MacroName & ": Step 2 of 3", "*.jpg")
   If DlgFileRet = "" Then Exit Sub
   
   ' Set title mode
   DlgModeTxt = "Titles added _during_ insertion: User or Filenames"
   DlgModeRet = InputBox(DlgModeTxt, MacroName & ": Step 3 of 3", "Filenames")
   If DlgModeRet = "" Then Exit Sub
   
   ' Returns _first_ file *.jpg found in indicated directory
   MyPics = Dir(DlgPathRet & "\" & DlgFileRet)
   
   ' Ensure slideview as macro can not run in slide sorter view
   ActiveWindow.ViewType = ppViewSlide
     
   ' Start the importing
   Do While MyPics <> ""
           
      ' Determine slide number of the new slide
      SlideNumber = ActivePresentation.Slides.Count + 1
      ' Add it at the end of the collection
      ActivePresentation.Slides.Add SlideNumber, ppLayoutTitleOnly
      ' and go there
      ActiveWindow.View.GotoSlide Index:=SlideNumber
           
      ' Add pictures. Size in inches, multiplied by 72 to convert in points
      ActivePresentation.Slides(SlideNumber).Shapes.AddPicture _
             (FileName:=DlgPathRet & "\" & MyPics, _
             LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, _
             Left:=1.06 * 72, Top:=0.75 * 72, Width:=8 * 72, Height:=6 * 72).Select
           
      ' Define when titles will be added
      If DlgModeRet = "User" Or DlgModeRet = "user" Then
         DlgTitleRet = InputBox("Title for " & MyPics, MacroName, "")
      Else
         DlgTitleRet = MyPics
      End If
     
      With ActivePresentation.Slides(SlideNumber).Shapes.Title.TextFrame.TextRange
         .Characters(Start:=1, Length:=0).Select
         .Text = DlgTitleRet
             With .Font
                .Name = "Times New Roman"
                .Size = 28
                .Bold = msoFalse
                .Italic = msoFalse
                .Underline = msoFalse
                .Shadow = msoFalse
                .Emboss = msoFalse
                .BaselineOffset = 0
                .AutoRotateNumbers = msoTrue
                .Color.SchemeColor = ppTitle
             End With
      End With
     
      ' Call Dir again w/o arguments to return next (DOS) indicated file
      MyPics = Dir
   Loop
     
   ' For visual check and eventual sorting
   ActiveWindow.ViewType = ppViewSlideSorter

End Sub
0
 

Author Comment

by:jwilk8284
ID: 2700986
cri,

Great job.  I like what you have done with this macro.  400 points is yours as well as my appreciation for taking on the problem and getting it solved.
0
 

Author Comment

by:jwilk8284
ID: 2700990
cri has been pleasant to deal with.
0
 
LVL 13

Expert Comment

by:cri
ID: 2701462
Thanks. You are welcome.

This was a nice exercise on how to get started with VBA:

a) Believe that there must be a way better than original Microsoft

b) Record macro.

c) Improve code:
- Make sure VBA help is installed, if I remember this correctly you must run Office setup again as not in default setup.
- This URL is handy to bookmark for later consultations (provided you have a cheap ISP/telecom or tons of printer paper)
http://msdn.microsoft.com/library/officedev/office97/web/fulltoc.htm

d) Use E-E if you get stuck. Powerpoint support is astonishingly low, but for Excel the expert competition is fierce and the code usually is good to excellent.
0
 

Expert Comment

by:tperegoy
ID: 14501921
This works well, but I have an issue along these lines.  I have scanned a number of old family photos.  Due to the photos being damaged, irregularly sized, or stuck in scrapbooks where it was hard to capture the original size - I cannot just assign a value to width and height.  In the above, you use width of 10 and height of 7.  These are multiplied by 72.   If I do that, my pictures are distorted in size.  

How can I use this macro to insert the photos but use the original size of the photo I scanned, or if you are really good, how can I set the height not greater than 7 and proportion the width, or set width not greater than 10 and proportion height?
0
 
LVL 13

Expert Comment

by:cri
ID: 14600304
It should not be difficult to improve this code, whereas I am not "really good", I am better than 5 years ago. At least regarding VBA....

However before I do this:
a) If you already solved it, please tell me so.
b) Regarding the photos. I did just a similar task. I cropped/resampled/resized them, as most graphic software are able. But granted cutting the pictures to keep the proportions is not always a good solution.  
0
 

Expert Comment

by:tperegoy
ID: 14606814
I have resolved my isue.   I asked this question (or one very similar to it) on my own thread.   See
http://www.experts-exchange.com/Applications/MS_Office/Q_21500822.html

In it, I can import any size picture and have it resized so one dimension fits the screen while the other is proportioned equally.  Whichever fits better, height or width, the other dimension is modified proportionately.   This works to increase or decrease the size to fit.  Then, it centers the photo in the slide.  I received some good help and then improvised to complete the rest.  I posted the final product on this link.

Thanks for the help!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question