Solved

Insert Multiple Pictures into different table cells in MS Word

Posted on 2013-05-14
5
5,243 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
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 use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now