Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2017, 11:17 AM
Fabulist Fabulist is offline Macro to resize all objects & pictures? Windows 10 Macro to resize all objects & pictures? Office 2016
Advanced Beginner
Macro to resize all objects & pictures?
 
Join Date: Sep 2015
Posts: 33
Fabulist is on a distinguished road
Default Macro to resize all objects & pictures?

Hello everyone!

I have multiple linked pictures and objects (including Excel worksheet objects) and I need to reset all their sizes to 100% after they are updated since they seem to break.

I tried the following macros but none worked:

1:


Code:
Sub Resize()
Dim i As Long
With ActiveDocument
    For i = 1 To .InlineShapes.Count
        With .InlineShapes(i)
            .ScaleHeight = 100
            .ScaleWidth = 100
        End With
    Next i
End With
End Sub
2:
Code:
Sub Resize()
    Dim Slide As InlineShape
    
    For Each Slide In ActiveDocument.InlineShapes
        With Slide
            If .Type = wdInlineShapeEmbeddedOLEObject Then
                .ScaleWidth = 100
                .ScaleHeight = 100
            End If
        End With
    Next
End Sub
3:
Code:
Sub Resize()
     Dim PecentSize As Integer

     PercentSize = 100

     If Selection.InlineShapes.Count > 0 Then
         Selection.InlineShapes(1).ScaleHeight = PercentSize
         Selection.InlineShapes(1).ScaleWidth = PercentSize
     Else
         Selection.ShapeRange.ScaleHeight Factor:=(PercentSize / 100), _
           RelativeToOriginalSize:=msoCTrue
         Selection.ShapeRange.ScaleWidth Factor:=(PercentSize / 100), _
           RelativeToOriginalSize:=msoCTrue
     End If
 End Sub
Am I thinking this in a wrong way? Nothing seems to budge.
Reply With Quote
  #2  
Old 01-17-2017, 02:01 PM
macropod's Avatar
macropod macropod is offline Macro to resize all objects & pictures? Windows 7 64bit Macro to resize all objects & pictures? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Depending on what you've inserted the inlineshape may or may not have a ScaleHeight or ScaleWidth value. Embedded & linked Excel workbooks and vector images, for example, are two formats that don't.

Also, images that have wrapping applied aren't inlineshapes and wouldn't be processed by your macros.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-17-2017, 11:15 PM
Fabulist Fabulist is offline Macro to resize all objects & pictures? Windows 10 Macro to resize all objects & pictures? Office 2016
Advanced Beginner
Macro to resize all objects & pictures?
 
Join Date: Sep 2015
Posts: 33
Fabulist is on a distinguished road
Default

Hello, no I do not have wrapping applied. The objects / pictures are simply link pasted in the Word file. The tables linked are actually calculated to fit the custom margins set in Word perfectly when set at 100% - 100% and are all classified as "In line with text".

Do you have any idea what value can work since ScaleHeight and ScaleWidth do not? Is there something else wrong?
Reply With Quote
  #4  
Old 01-18-2017, 02:37 PM
macropod's Avatar
macropod macropod is offline Macro to resize all objects & pictures? Windows 7 64bit Macro to resize all objects & pictures? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

As I said previously, embedded & linked Excel objects do not have ScaleHeight and ScaleWidth values. Accordingly, you can't resize them using such an approach. The same applies to vector images and, AFAIK, embedded & linked OLE objects generally. Accordingly, if you want to constrain them to a particular size, you'd need to set the dimensions explicitly. An alternative approach would be to insert those objects into single-celled Word tables having a fixed height and width:
• For the rows, set the exact row height under Table Tools>Layout>Properties>Row>Specify Height>Exactly.
• For the columns, set the preferred column width under Table Tools>Layout>Properties>Columns and uncheck the 'automatically resize to fit contents' option under Table Tools>Layout>Properties>Table>Options.

However, if you're simply trying to prevent the unwanted resizing of linked objects:
1. Open the Registry Editor, then navigate to:
HKEY_CURRENT_USER\Software\Microsoft\Office\#\Exce l\Options
where # is your Office version number.
2. Add a new DWORD value: QFE_Boston
3. Set the new DWORD value to 1
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-19-2017, 01:30 AM
Fabulist Fabulist is offline Macro to resize all objects & pictures? Windows 10 Macro to resize all objects & pictures? Office 2016
Advanced Beginner
Macro to resize all objects & pictures?
 
Join Date: Sep 2015
Posts: 33
Fabulist is on a distinguished road
Default

Thank you for taking your time informing me regarding this, I will investigate with your alternatives, as they seem to provide a better solution to my problems.

Thanks again!
Reply With Quote
Reply

Tags
macro, resize objects, resize pictures



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shift key not working to resize objects liambobrien PowerPoint 2 12-16-2015 11:03 AM
Macro to resize all objects & pictures? Resize multiple PowerPoint objects in a table at the same time Duradel Word Tables 3 11-16-2014 04:01 PM
Macro to resize all objects & pictures? Resize multiple pictures in a Word 2010 table JBA479 Word VBA 1 01-24-2014 08:51 PM
Resize and distribute width - 2 pictures AndyDDUK PowerPoint 2 10-10-2012 03:38 AM
Resize Email pictures in Outlook - Office 2007? jonesnewton Outlook 0 05-16-2010 04:11 AM

Other Forums: Access Forums

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