-
Aug 8th, 2006, 07:44 PM
#1
Thread Starter
New Member
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
-
Aug 8th, 2006, 08:35 PM
#2
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:
Do Until ActiveSheet.Shapes.Count = 0
will never test true.
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:
Public Sub ResizePics()
Dim oDoc As Document, oShape As InlineShape
Set oDoc = Application.ActiveDocument
For Each oShape In oDoc.InlineShapes
oShape.Height = 270
oShape.Width = 360
Next oShape
Set oDoc = Nothing
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.
-
Aug 8th, 2006, 10:25 PM
#3
Thread Starter
New Member
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
-
Aug 8th, 2006, 11:34 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|