Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compress Images in Word? 1

Status
Not open for further replies.

Wurkle

Technical User
Sep 24, 2002
15
0
0
GB
To reduce disk space usage I am trying to automatically compress images in a word file.
Users have been shown how to manually do this but soon forget to carry out the process, so am going for a prompt on save approach.
Have been trying to use Shapes object, but so far it's defeating me 8-(
 

Hi,

Have you tried using your macro recorder?

Skip,
[sub]
[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue][/sub]
 
Hi Skip

Yes, started with the recorder but it doesn't seem to capture the compress event...
 


Look at the ConvertTo method

ConvertTo Method Example

This example creates a new document, then inserts an embedded Word document with some text. Then, the embedded document is converted to a Word Picture.
Code:
Documents.Add
Set myEmbedded = ActiveDocument.Shapes _
    .AddOLEObject(ClassType:= "Word.Document")
myEmbedded.Activate
Selection.TypeText "Test"
myEmbedded.OLEFormat.OLEFormat.ConvertTo _
    ClassType:="Word.Picture"

Skip,
[sub]
[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue][/sub]
 
Skip

Still struggling, the inserted images (jpg's) are now causing a test file to be 40x the file size of the image.

Might go for a message on save if the doc contains images with a scale of less than 100%...

Wurkle


 
Hi Wurkle,

you say
Users have been shown how to manually do this

what method is used exactly?


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Hi Glenn

In Word 2002,
Right click image & select "Format Picture..."
Select Picture tab
Click "Compress..." button
Set options as follows: (Apply to) All Pictures in Document, (Change Resolution) Print, (Options) Compress Pictures & Delete cropped areas of pictures
Click OK, accept warning (if appears) & OK to close.

Although not as efficient as changing with imaging software it's pretty good & much easier for users.

Wurkle
 
Cam you tell me what Compress does? I just did a file with images, used that Compress method, and the file size did not change a single byte. The original file and the "compressed" file are precisely the same size. So....what does it do?

Gerry
 
There is no programmatic compression of pictures in office xp, you can only simplify the way to access compression dialog. You can either make it available at single button click (customise one of visible toolbars by adding compression button; can be found in commands > drawing (category)), or displayed automatically when closing document.
The code in ThisDocument module of template (Normal in my case):

Private Sub Document_Close()
Dim cbc As Office.CommandBarControl
Set cbc = CommandBars.FindControl(ID:=6382)
cbc.Execute
Set cbc = Nothing
End Sub

You can add code that tests if document was changed or contains any picture, but for me the button can male compression simple enough for average user.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top