View Single Post
 
Old 04-23-2017, 08:15 PM
rms42 rms42 is offline Windows 8 Office 2013
Novice
 
Join Date: Apr 2017
Posts: 1
rms42 is on a distinguished road
Default Formatting Inserted Images (6 to a page)

I'm looking to make a macro that will do the following:

1. Insert all selected photos from a specified folder into the word document.
2. Wrap text square for all images.
3. Format the images, 6 to a page like in the image below:


I did some digging on the web and found the following macro that inserts all selected images into the word document:

Code:
Sub InsertImages()
    Dim doc As Word.Document
    Dim fd As FileDialog
    Dim vItem As Variant
    Dim mg1 As Range
    Dim mg2 As Range

    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    Set doc = ActiveDocument

    With fd
        .Filters.Add "Images", "*.gif; *.jpg; *.jpeg", 1
        .FilterIndex = 1

        If .Show = -1 Then
            For Each vItem In .SelectedItems
                Set mg2 = ActiveDocument.Range
                mg2.Collapse wdCollapseEnd
                doc.InlineShapes.AddPicture _
                  FileName:=vItem, _
                  LinkToFile:=False, SaveWithDocument:=True, Range:=mg2
                Set mg1 = ActiveDocument.Range
                mg1.Collapse wdCollapseEnd

                mg1.Text = vbCrLF & vbCrLf
            Next vItem
        End If
    End With

    Set fd = Nothing
End Sub
Any help is appreciated. Thanks!
Reply With Quote