Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-25-2020, 02:31 AM
alex100 alex100 is offline Resize images multiple times Windows 7 64bit Resize images multiple times Office 2016
Advanced Beginner
Resize images multiple times
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default Resize images multiple times

The code below resizes all the images in a document to a fixed width & height, and then applies some properties to each image found.



It works well, with one drawback - it resizes the images only one time. I believe this is because the images are first converted from 'InlineShape' to 'Shape', and the second time you run the script, it will no longer find any 'InlineShape' image to convert.

What could I do to apply those properties to the images, and then have them resized multiple times, in various sizes?

Among other things, I tried adding 'oShape.ConvertToInlineShape' at the end of the loop, but without any success.

Alex

Code:
Dim oDoc As Document, oShape As InlineShape
Set oDoc = Application.ActiveDocument
For Each oShape In oDoc.InlineShapes
    oShape.Width = 200
    oShape.Height = 200
    oShape.Select
    Selection.Fields.Unlink
    Set os = oShape.ConvertToShape
    With os
        .WrapFormat.Type = wdWrapTopBottom
        .WrapFormat.AllowOverlap = False
        .Left = wdShapeCenter
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    End With
Next oShape
Set oDoc = Nothing
Reply With Quote
  #2  
Old 05-25-2020, 04:07 AM
Guessed's Avatar
Guessed Guessed is offline Resize images multiple times Windows 10 Resize images multiple times Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
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

An inline shape is one which allows text wrapping or sits above of below text. Once you have converted to a shape, you can set it back to inline but your code to set text wrapping would be pointless as this is exactly what Inline shapes DON'T DO.

If you want to also catch Shapes then you need a second loop for Shapes
eg
Dim aShp as Shape
For each aShp in oDoc.Shapes
'do stuff
Next aShp
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 05-25-2020, 07:06 AM
alex100 alex100 is offline Resize images multiple times Windows 7 64bit Resize images multiple times Office 2016
Advanced Beginner
Resize images multiple times
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default

Thank you, Andrew!

Eventually, I did manage to find a solution. I simply converted all the 'msoPicture' type of InlineShapes into Shapes, and then resized and applied those properties to all Shapes in the document.

Alex
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro: insert muliple images and resize into given cells marco83 Excel Programming 1 08-15-2018 09:16 AM
Resize images multiple times How to automatically resize images and place them to neeeded positions xerxox Drawing and Graphics 1 08-09-2018 02:44 PM
Resize images multiple times Import images, resize them, and fit them to specific locations on the page hysterical.useless Drawing and Graphics 8 01-30-2018 04:27 PM
Resize images multiple times Help Creating Macro to Crop/Resize Images ineedmacrohelp Word VBA 1 08-06-2015 06:46 AM
Resize images multiple times Help with VBA to resize images Yuffster Word VBA 2 01-30-2015 06:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:23 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