Solved

Insert Multiple Pictures into different table cells in MS Word

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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 create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

821 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