Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-06-2018, 12:19 AM
Guessed's Avatar
Guessed Guessed is offline How do I change multiple pictures in Word 2016 to all new pictures that appear in a specified order? Windows 10 How do I change multiple pictures in Word 2016 to all new pictures that appear in a specified order? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this code - the macro is called ReplaceImages. It is written to run from the current selection point to the end of the document and continuously open the usual dialog until it runs out of pictures in the document.
It doesn't include a method of breaking the code if choose to stop before reaching the end of the document. The logical way to do that would be to detect if a dialog was dismissed by pressing Cancel but I'm not sure how I would do that. Someone else might have a good idea on how to do that.
Code:
Sub ReplaceImages()
  Dim i As Integer, aRng As Range
  Set aRng = Selection.Range
  aRng.End = ActiveDocument.Range.End
  For i = 1 To aRng.InlineShapes.Count
    aRng.InlineShapes(i).Select
    funReplaceInlineShape aRng.InlineShapes(i)
  Next i
End Sub

Function funReplaceInlineShape(origShp As InlineShape) As Boolean
  Select Case origShp.Type
    Case msoAutoShape, msoFreeform, 6   'this is a shape with a picture fill
      CommandBars.ExecuteMso ("ObjectPictureFill")
    Case wdInlineShapePicture      'this is a picture placed into the doc
      If CInt(Application.Version) < 16 Then   'following only works pre Word 2016+
          CommandBars.ExecuteMso ("PictureChange")
        Else                    'following is for Word 2016+
          CommandBars.ExecuteMso ("PictureChangeFromFile")
      End If
  End Select
End Function
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
macro help, word 2016-64, word table



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change multiple pictures in Word 2016 to all new pictures that appear in a specified order? Pictures within doc print way too small: word 2016 pamaples Word 4 08-27-2018 03:02 PM
Text prints OK, pictures print way too small: Word 2016 doc pamaples Drawing and Graphics 0 04-27-2017 09:14 AM
How do I change multiple pictures in Word 2016 to all new pictures that appear in a specified order? Word 2016 Not Auto Aligning Pictures to Text CrossReach Word 2 01-21-2017 08:14 AM
How do I change multiple pictures in Word 2016 to all new pictures that appear in a specified order? Word 2013 - pictures inserted into word appear in two different formats, need to change katm3 Word 4 05-22-2015 12:53 AM
How do I change multiple pictures in Word 2016 to all new pictures that appear in a specified order? Resize multiple pictures in a Word 2010 table JBA479 Word VBA 1 01-24-2014 08:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:56 PM.


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