Solved

Insert Multiple Pictures into different table cells in MS Word

Posted on 2013-05-14
5
6,742 Views
Last Modified: 2015-01-16
Hi Experts,

This is probably really simple but its driving me crazy. I am trying to insert a lot of pictures into a word table because I need to get two of them per page.

I create the table and set the exact size I want so the table doesnt adjust to the size of the picture and it works well. I can insert pictures one by one and its no problem. However since there are MANY pictures, I select the whole table and then try to import the pictures so I can get 1 per cell... but they seem to be imported to the first cell instead of 1 per cell. I tried this also with copy and pasting the pictures with the same results.

Anyone have a workaround?

Thanks in advance!
0
Comment
Question by:Nauj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
BurundiLapp earned 125 total points
ID: 39165138
It's a little convoluted but possible to a degree.

In a blank page insert all your pictures
go back to the top of the document and press the left arrow key
put in a comma
repeat for however many columns you will have in your table
whenever a new row should start (i.e after say 6 pictures) then press enter instead of putting a comma in.

When done

Select all ( CTRL + A )
In Word 2010 click the 'insert' ribbon bar bar
Then click the dropdown arrow under Table
Choose convert text to table, it should have detected you are using commas to seperate the pictures and detected the correct number of columns due to you putting in paragraph returns instead of commas.

Once this has been done you'll have all the pictures in consecutive cells in a table, you can then resize the table to how it should be, not sure if the pictures will need resizing as well, it depends on the way they look.
0
 
LVL 14

Assisted Solution

by:Stacy Brown
Stacy Brown earned 125 total points
ID: 39165176
I think you are stuck unless you have all the pictures in a database or in Excel.  Then you could use mailmerge.

I found this code here that may help:  http://www.vbaexpress.com/forum/showthread.php?t=44473

Sub AddPics() 
    Application.ScreenUpdating = False 
    Dim oTbl As Table, i As Long, j As Long, k As Long, StrTxt As String 
     'Select and insert the Pics
    With Application.FileDialog(msoFileDialogFilePicker) 
        .Title = "Select image files and click OK" 
        .Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp; *.tif; *.png" 
        .FilterIndex = 2 
        If .Show = -1 Then 
             'Add a 2-row by 2-column table with 7cm columns to take the images
            Set oTbl = Selection.Tables.Add(Selection.Range, 2, 2) 
            With oTbl 
                .AutoFitBehavior (wdAutoFitFixed) 
                .Columns.Width = CentimetersToPoints(7) 
                 'Format the rows
                Call FormatRows(oTbl, 1) 
            End With 
            CaptionLabels.Add Name:="Picture" 
            For i = 1 To .SelectedItems.Count 
                j = Int((i + 1) / 2) * 2 - 1 
                k = (i - 1) Mod 2 + 1 
                 'Add extra rows as needed
                If j > oTbl.Rows.Count Then 
                    oTbl.Rows.Add 
                    oTbl.Rows.Add 
                    Call FormatRows(oTbl, j) 
                End If 
                 'Insert the Picture
                ActiveDocument.InlineShapes.AddPicture _ 
                FileName:=.SelectedItems(i), LinkToFile:=False, _ 
                SaveWithDocument:=True, Range:=oTbl.Rows(j).Cells(k).Range 
                 'Get the Image name for the Caption
                StrTxt = Split(.SelectedItems(i), "\")(UBound(Split(.SelectedItems(i), "\"))) 
                StrTxt = ": " & Split(StrTxt, ".")(0) 
                 'Insert the Caption on the row below the picture
                With oTbl.Rows(j + 1).Cells(k).Range 
                    .InsertBefore vbCr 
                    .Characters.First.InsertCaption _ 
                    Label:="Picture", Title:=StrTxt, _ 
                    Position:=wdCaptionPositionBelow, ExcludeLabel:=False 
                    .Characters.First = vbNullString 
                    .Characters.Last.Previous = vbNullString 
                End With 
            Next 
        Else 
        End If 
    End With 
    Application.ScreenUpdating = True 
End Sub 
 '
Sub FormatRows(oTbl As Table, x As Long) 
    With oTbl 
        With .Rows(x) 
            .Height = CentimetersToPoints(7) 
            .HeightRule = wdRowHeightExactly 
            .Range.Style = "Normal" 
        End With 
        With .Rows(x + 1) 
            .Height = CentimetersToPoints(0.75) 
            .HeightRule = wdRowHeightExactly 
            .Range.Style = "Caption" 
        End With 
    End With 
End Sub 

Open in new window


Also, this Photo Gallery Addin from Greg Maxey that may help:

http://gregmaxey.mvps.org/word_tip_pages/photo_gallery_add_in.html
0
 
LVL 14

Expert Comment

by:Stacy Brown
ID: 39165185
BurundiLapp ....  That's a great idea!  I didn't even think of that.  Nice one!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

732 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