Solved

Resize images within a Word document

Posted on 2004-08-17
2
200 Views
Last Modified: 2011-09-20
I'm trying to write a VB program that will open a Word document and resize all the images contained within.  This document may have as many as 20 images.  I have tried the following with little success. The first image resizes but the remaining images do not.

   Dim objWordApp As New Word.Application
   Dim objWordDoc As New Word.Document
   
   Set objWordDoc = objWordApp.Documents.Add("WordDocument.doc")

   ' Loop through the images
   For cnt = 0 To (objWordDoc.InlineShapes.Count - 1)
      objWordDoc.InlineShapes(cnt).Width = 250
      objWordDoc.InlineShapes(cnt).Height = 250
   Next

   objWordDoc.Save
0
Comment
Question by:TheChos
2 Comments
 
LVL 18

Accepted Solution

by:
JR2003 earned 500 total points
ID: 11823532
Dim iShape As InlineShape
For Each iShape In ActiveDocument.InlineShapes
    iShape.Width = 250
    iShape.Height = 250
Next iShape
0
 

Author Comment

by:TheChos
ID: 11823617
Excellent!

It's very obvious after reading your solution.  I can't believe I didn't think of it.  Thanks again.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now