Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 09-30-2014, 06:44 PM
vjc21 vjc21 is offline Compressing pictures in Word 2010 Windows 7 64bit Compressing pictures in Word 2010 Office 2010 32bit
Novice
Compressing pictures in Word 2010
 
Join Date: Jun 2014
Posts: 1
vjc21 is on a distinguished road
Default Compressing pictures in Word 2010

Hi all,



I am wanting to compress pictures in word 2010 using VBA. I have already scaled the inserted pictures, but need to still reduce the overall size of the document.

I am using the below code to try and accomplish this:-

Code:
With Application.CommandBars.FindControl(ID:=6382)
    SendKeys "%A%W{Enter}"
     .Execute
End With
but the sendkeys doesn't seem to be working correctly. (Word 2010 32bit, win 7 64bit)

When I do it manually I get a different compress pictures dialog box (first attachment) verse when being called in code (older possible 2003 version), even thought they both share the same ID of 6382.

I understand that it should really be done outside of word, but the end user, due to company policies is not able to install decent graphical software to compress pictures. They have to put the picture into word as a requirement of the report that are doing, so I was hoping to do it there.

I have also changed the default compression of images in the word options so that all new documents are created with a reduced dpi, but the document is still too large.

Is there a work around in vba to achieve the same result.
Attached Images
File Type: png 2014-10-01 10_14_13-Compress Pictures.png (11.2 KB, 20 views)
File Type: png 2014-10-01 10_19_04-Compress Pictures.png (9.9 KB, 20 views)
  #2  
Old 09-30-2014, 09:12 PM
macropod's Avatar
macropod macropod is online now Compressing pictures in Word 2010 Windows 7 64bit Compressing pictures in Word 2010 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

That looks like some code I posted at: http://social.msdn.microsoft.com/For...?forum=worddev

The code isn't meant to display a dialogue; it merely sets Word's compression to 'Web' resolution (96dpi). Changing the SendKeys code to:
SendKeys "%A%P{Enter}"
would sets Word's compression to 'Print' resolution (200dpi). That code works for Word 2003 & earlier, but not for Word 2007 & later. Although Word 2007 & later contain the same command bar, it doesn’t work. Indeed Word 2007 & later contain two command bars with the same ID - as your post shows - but it’s only the older non-functioning one the code activates. Since there is no difference in the IDs, there is no way to control which version Word serves up. According to the VBA help file:
Quote:
If the CommandBars collection contains two or more controls that fit the search criteria, FindControl returns the first control that's found.
Although one can also specify other attibutes to differentiate one control from another (e.g. Type:=1 for a button, or Tag:= something), I can't find anything to differentiate them. Even using the Visible:=True parameter with the Pictures Tools tab visible doesn't help. You'll probably need to find another method.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #3  
Old 10-04-2021, 08:38 PM
James Martin James Martin is offline Compressing pictures in Word 2010 Windows 10 Compressing pictures in Word 2010 Office 2019
Novice
 
Join Date: Sep 2021
Posts: 7
James Martin is on a distinguished road
Default

Looks like Windows are not supporting this. I am trying the code as well. I need it for work as we have to get files down under a 4MB limit. I have Office 365.Would be great to have a list box UserForm with a choice of 150ppi or 95ppi. Perhaps the FindControl ID has changed?
  #4  
Old 10-05-2021, 05:23 PM
macropod's Avatar
macropod macropod is online now Compressing pictures in Word 2010 Windows 10 Compressing pictures in Word 2010 Office 2016
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

Quote:
Originally Posted by James Martin View Post
Looks like Windows are not supporting this.
No, as discussed nearly eight years ago, it's Word that doesn't support it...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compressing pictures in Word 2010 Resize multiple pictures in a Word 2010 table JBA479 Word VBA 1 01-24-2014 08:51 PM
How to automatically insert pictures the same size in word 2010 mindblaster Word 2 03-07-2013 11:42 AM
Compressing pictures in Word 2010 How to prevent Compressing images in Word 2010 ramsgarla Word 1 11-21-2012 04:47 PM
Need help compressing a document strewart Word 0 11-05-2009 09:05 PM
Compressing images Fran PowerPoint 0 10-29-2009 07:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:48 PM.


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