Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2017, 08:15 PM
rms42 rms42 is offline Formatting Inserted Images (6 to a page) Windows 8 Formatting Inserted Images (6 to a page) Office 2013
Novice
Formatting Inserted Images (6 to a page)
 
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
  #2  
Old 04-23-2017, 08:24 PM
gmayor's Avatar
gmayor gmayor is offline Formatting Inserted Images (6 to a page) Windows 10 Formatting Inserted Images (6 to a page) Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See http://www.gmayor.com/photo_gallery_template.html
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 04-23-2017, 11:17 PM
macropod's Avatar
macropod macropod is offline Formatting Inserted Images (6 to a page) Windows 7 64bit Formatting Inserted Images (6 to a page) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See also: https://www.msofficeforums.com/word-...html#post47919
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Inserted Images (6 to a page) Major problems inserted images into Word EsoxL Word 4 01-30-2015 06:48 PM
Formatting Inserted Images (6 to a page) Generally disable alt text for images inserted into a .docx Lebber Word 2 01-24-2013 11:25 AM
Formatting Inserted Images (6 to a page) Inserted images constantly SHIFTING in text! Why?!!!! corrinnecareens Drawing and Graphics 1 04-08-2012 11:32 PM
Formatting Inserted Images (6 to a page) Inserted images don't appear terence_laoshi Drawing and Graphics 2 04-14-2011 05:08 AM
Formatting Inserted Images (6 to a page) Why are images so big when inserted into Word? WaltR Word 2 02-13-2011 10:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft