Solved

Insert Multiple Pictures into different table cells in MS Word

Posted on 2013-05-14
5
5,877 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
  • 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 13

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 13

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

776 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