Results 1 to 4 of 4

Thread: Resizing Multiple Identical Images in Word

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    4

    Resizing Multiple Identical Images in Word

    Hi,

    I am new to VB but have been applescripting for some time. What I would like to do is to select ALL exsisting identical pictures in word document and resize them all. I have pasted what I have done so far, but I am sure that I am way off base. Any help would be greatly appreciated!

    Keith

    PS.. I attempted to record this action but once I start recording, it will not let me select an image at all. Help with what I am doing wrong here would be appreciated also!

    Sub TEST2()
    '
    ' TEST2 Macro

    '
    Do Until ActiveSheet.Shapes.Count = 0
    For i = 1 To Active.Shapes.Count
    ActiveSheet.Shapes(i).Select
    ActiveSelection.Shapes(i).Height = 270#
    ActiveSelection.Shapes(i).Width = 360#
    Next i
    Loop

    End Sub

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Resizing Multiple Identical Images in Word

    Well, from the first glance it looks like your loop will never exit. If there are any shapes in the document, this line:
    VB Code:
    1. Do Until ActiveSheet.Shapes.Count = 0
    will never test true.
    Quote Originally Posted by BUYAMAC
    What I would like to do is to select ALL exsisting identical pictures in word document and resize them all.
    Do you want all of the images resized, or just ones that meet a specific criteria? This will resize all of them:
    VB Code:
    1. Public Sub ResizePics()
    2.  
    3.     Dim oDoc As Document, oShape As InlineShape
    4.    
    5.     Set oDoc = Application.ActiveDocument
    6.    
    7.     For Each oShape In oDoc.InlineShapes
    8.         oShape.Height = 270
    9.         oShape.Width = 360
    10.     Next oShape
    11.    
    12.     Set oDoc = Nothing
    13.  
    14. End Sub
    If you only want to resize some of them, you'll have to add some sort of test to determine if the oShape is one that fits your criteria.
    Last edited by Comintern; Aug 8th, 2006 at 08:35 PM. Reason: Fix quote tag.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2006
    Posts
    4

    Re: Resizing Multiple Identical Images in Word

    Comintern:

    Thanks! I really appreciate it! That worked liked a charm (as you knew it would)...

    I could use some good primers on VB? Any suggestions?

    Thanks Again,
    Keith

  4. #4
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Resizing Multiple Identical Images in Word

    No problem. I would recommend using the Macro recorders, and also the VBA programming reference in the office products help files. Usually, the macro recorder writes pretty sloppy code, but it's good for identifying what the objects that you need to work with are. From that point, it's usually a good idea to go into the object model reference and start looking through the properties, methods, etc. The documentation in the office help files is invaluable.

    Of course, VBForums is also a great resource . I learned a ton by reading through other peoples code and solutions to problems. Copying them into your IDE and stepping through them with the debugger is always a great way to pick up how things work.
    Last edited by Comintern; Aug 8th, 2006 at 11:35 PM. Reason: typo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width