Microsoft Office Forums Align and Distribute Images in Word with a Macro

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2019, 04:01 PM
DaveP DaveP is offline Align and Distribute Images in Word with a Macro Windows 10 Align and Distribute Images in Word with a Macro Office 2010
Novice
Align and Distribute Images in Word with a Macro
 
Join Date: May 2019
Posts: 11
DaveP is on a distinguished road
Default Align and Distribute Images in Word with a Macro

Hello,

I am trying to get multiple (usually 3) images to align to each other. Basically, they need to be the same height, have a 1 inch border, aligned at the top, equidistant from each other(we can say .5 inches, I haven't decided yet), and all in a group. Here's what I have so far-- you select all 3 images and run this macro:


Sub Test()
Set myShapeRange = Selection.ShapeRange
myShapeRange.Align msoAlignTops, False
With myShapeRange


.Line.Weight = 1
.Line.Visible = msoTrue
.LockAspectRatio = msoTrue
.Height = InchesToPoints(1.5)
End With
Selection.ShapeRange.Group.Select
End Sub


The process is we paste in 3 images and then do all of that stuff individually, so it's a nice time saver (we do it several hundred times a day, the time adds up). The only thing this won't do is distribute them evenly, and with a set distance from each other. I can click "distribute horizontally" in the format menu, but I want to be able to adjust how close the images are to each other (distribute horizontally makes them distribute inside of the total space the images cover originally). Any help is welcomed!! Thanks!



TL;DR: pictures need to be .5 inches away from each other and aligned at their tops
Reply With Quote
  #2  
Old 05-14-2019, 04:14 PM
eduzs eduzs is offline Align and Distribute Images in Word with a Macro Windows 10 Align and Distribute Images in Word with a Macro Office 2010 32bit
Competent Performer
 
Join Date: May 2017
Posts: 157
eduzs is on a distinguished road
Default

Maybe a way to do that is the macro to create a table with 3 columns and then insert the images in each cell.
If the images are always the same size you can set rows height and coumns width as desired.
Also the paragraph alignment of the cell can be used to get the desired result.
__________________
Backup your original file before doing any modification, test in a throwaway copy of your file.
Reply With Quote
  #3  
Old 05-14-2019, 05:10 PM
gmaxey gmaxey is offline Align and Distribute Images in Word with a Macro Windows 10 Align and Distribute Images in Word with a Macro Office 2016
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 902
gmaxey will become famous soon enoughgmaxey will become famous soon enough
Default

You might try https://gregmaxey.com/word_tip_pages...ry_add_in.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 05-14-2019, 07:29 PM
macropod's Avatar
macropod macropod is offline Align and Distribute Images in Word with a Macro Windows 7 64bit Align and Distribute Images in Word with a Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,533
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

See: https://www.msofficeforums.com/word-...html#post47919
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 05-15-2019, 02:38 PM
DaveP DaveP is offline Align and Distribute Images in Word with a Macro Windows 10 Align and Distribute Images in Word with a Macro Office 2010
Novice
Align and Distribute Images in Word with a Macro
 
Join Date: May 2019
Posts: 11
DaveP is on a distinguished road
Default Can't use a textbox

the pictures are never ever the same size-- screen shots from websites, not always the same websites, not always the same width (however, they are always the same height). I had made a version of this with a text box, but the department came back to me and showed how the text box is too limiting and inconsistent because of the width differences every time.

Is there not a way to standardize the distribution between images? Like, how if you click "distribute horizontally", it makes the two white spaces between the three images equal. Is there no way to distribute horizontally to a defined value?
Reply With Quote
  #6  
Old 05-15-2019, 04:22 PM
macropod's Avatar
macropod macropod is offline Align and Distribute Images in Word with a Macro Windows 7 64bit Align and Distribute Images in Word with a Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,533
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

You might at least try the code in the link I posted...
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 05-16-2019, 01:04 PM
DaveP DaveP is offline Align and Distribute Images in Word with a Macro Windows 10 Align and Distribute Images in Word with a Macro Office 2010
Novice
Align and Distribute Images in Word with a Macro
 
Join Date: May 2019
Posts: 11
DaveP is on a distinguished road
Default I have a new issue

I did and oh my god that's so cool haha. I didn't realize you could make Input Boxes. It didn't necessarily make what I needed it to make, but I think I could rewrite parts/dimensions and it would work great.

That being said,


So I actually semi resolved the issue with what I had written, and kind of streamlined it, so the original issue is resolved.

BUT-- I gave it to the department, they ran it, and it didn't work at all (it worked fine for me). So I had her send me the document, and I checked the file, and it is in Compatibility mode. For reasons that I do not understand and cannot explain, our company has to have everything in compatibility mode.

I converted her document to the most up-to-date version, and the macro ran exactly how I meant it to. Not sure if I'm allowed to post links on this forum, but this shows how Word treats pictures differently in different versions:

https://answers.microsoft.com/en-us/...2-c7df89c4fa57

Any idea why something wouldn't work between versions?

I'm going to mess around with what you sent me. I at least now have a new thing to practice/learn!! Thanks so much!
Reply With Quote
  #8  
Old 05-16-2019, 02:50 PM
macropod's Avatar
macropod macropod is offline Align and Distribute Images in Word with a Macro Windows 7 64bit Align and Distribute Images in Word with a Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,533
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Whether the document is set to compatibility mode is immaterial. Neither is the Word version of any consequence. I'd suggest the non-performance for whoever you sent it to was due to user error.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Align and Distribute Images in Word with a Macro Looking for Macro to Export Images alex20850 Word VBA 2 01-10-2019 06:27 PM
How to align this in the word table ValentinaZaharia Word 2 12-06-2018 01:58 PM
Align and Distribute Images in Word with a Macro How to link images by default when dragging images in word maxbaeten Drawing and Graphics 3 09-27-2017 11:34 PM
Align and Distribute Images in Word with a Macro I want to enlarge images in word when I click on them by using a macro MarloweCavendish Word VBA 1 08-16-2016 03:55 PM
Align and Distribute Images in Word with a Macro text to align on Microsoft Word for Mac mrstwitch Word 1 08-15-2015 01:33 AM


All times are GMT -7. The time now is 04:46 AM.


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