PDA

View Full Version : Solved: Macro / VBA to Compress Picture



dumbpuppy
11-14-2007, 07:51 AM
I am delivering a polwerpoint presentation to a large sales force. I am offering all automation via objects (buttons, text fields, etc) which are visible when in View Show Mode. I need to deliver the same functionality for compressing pictures which can be achieved by doing the following:

Format Pictures -->
Compress -->
Apply to All Pictures in document

I have tried using macro record to see how powerpoint would reflect the steps and the resulting macros is blank.

The best idea I have read so far is to utilize "send keys" but this has serious challenges as well....

I have done some research and this is evidently a tough issue. Major gold star for anyone who can help me find a good solution. Btw, the end game is too optimize file size reduction.

Thanks

TrippyTom
11-14-2007, 07:54 AM
Well, the quick answer is to check out PPTools. They have an addin specifically for this (called "Optimizer") and it works great:
http://www.pptools.com/downloads.htm

dumbpuppy
11-14-2007, 08:01 AM
Well, the quick answer is to check out PPTools. They have an addin specifically for this (called "Optimizer") and it works great:
http://www.pptools.com/downloads.htm

Thank you for the suggestion. My main concern with that solution is that I need to be able to distribute the presentaiton and all addins need to be installed on the client.

Do you know if there is a way to distribute a presentation with the pptools addin intact? I would purchase it in a second!

TrippyTom
11-14-2007, 08:11 AM
I'm not sure. I have emailed the author of those tools and he's a really nice guy. I'm only assuming, but he might be able to work out a deal if he doesn't have one in place already.

I would still like to know how to do this myself - just for learning sake.

dumbpuppy
11-14-2007, 08:19 AM
I'm not sure. I have emailed the author of those tools and he's a really nice guy. I'm only assuming, but he might be able to work out a deal if he doesn't have one in place already.

I would still like to know how to do this myself - just for learning sake.

You are a good man! Thank you for making the inquiry on my behalf. I will stay tuned. Meanwhile, if I figure something out I'll post the solution.

Thanks again

TrippyTom
11-14-2007, 08:23 AM
Nonono... I meant I emailed him in the past for other addins he wrote! :)

The shape styles and starter set he wrote are very useful! I paid him for both of those because I use it so much.

dumbpuppy
11-14-2007, 08:30 AM
OK. No Problem. I'll email the author myself and see if he can offer any advise. Even with a fee it would be worth it.
You're still a good man Trippy!:nya:

TrippyTom
11-14-2007, 09:14 AM
Here's another one that seems to be cheaper, but I haven't tried it. Maybe it doesn't work as well.

http://www.nxpowerlite.com/index.php?ld=n

Paul_Hossler
11-14-2007, 09:31 PM
Q: would you not want to compress all the pictures before distributing the presentation?

It sounds to me like you want the end users to be able to compress the picture, similar to a navigation Action Button, and I can't see how they would need to do that?:dunno

If you just want to make the file size small, PP2003+ has a Compress Picture option. From Help:


Select one or more pictures (picture: A file (such as a metafile) that you can ungroup and manipulate as two or more objects or a file that stays as a single object (such as bitmaps).) (http://javascript<b></b>:AppendPopup(this,'OfPicture_1')) in a file.
On the Picture toolbar (toolbar: A bar with buttons and options that you use to carry out commands. To display a toolbar, click Customize on the Tools menu, and then click the Toolbars tab.) (http://javascript<b></b>:AppendPopup(this,'IDH_oftipToolbar_2')), click Compress Picture http://office.microsoft.com/global/images/default.aspx?AssetID=ZA060437461033. Note If you do not see the Picture toolbar, point to View, then point to Toolbars, and then click Picture.
Select the options you want.Note Selecting the Delete cropped areas of pictures check box discards the parts of the picture that were hidden during cropping (crop: To trim vertical or horizontal edges of an object. Pictures are often cropped to focus attention on a particular area.) (http://javascript<b></b>:AppendPopup(this,'ofCrop_3')).

Paul

silvastre
04-04-2008, 05:11 AM
I am delivering a polwerpoint presentation to a large sales force. I am offering all automation via objects (buttons, text fields, etc) which are visible when in View Show Mode. I need to deliver the same functionality for compressing pictures which can be achieved by doing the following:

Format Pictures -->
Compress -->
Apply to All Pictures in document

I have tried using macro record to see how powerpoint would reflect the steps and the resulting macros is blank.

The best idea I have read so far is to utilize "send keys" but this has serious challenges as well....

I have done some research and this is evidently a tough issue. Major gold star for anyone who can help me find a good solution. Btw, the end game is too optimize file size reduction.

Thanks

Hi,

I think sendkeys is the best solution together with FindControl. The following code works in PPT 2003 english version. You may need to change %A (Alt+a)and %W (Alt+W) to other keys to navigate the dialogbox.

Sub compress()
Application.CommandBars.FindControl(Id:=6382).Execute
SendKeys "%A%W{ENTER}", False
End Sub

Happy programming
:)

/silvastre

dumbpuppy
04-04-2008, 09:17 AM
Hi,

I think sendkeys is the best solution together with FindControl. The following code works in PPT 2003 english version. You may need to change %A (Alt+a)and %W (Alt+W) to other keys to navigate the dialogbox.

Sub compress()
Application.CommandBars.FindControl(Id:=6382).Execute
SendKeys "%A%W{ENTER}", False
End Sub

Happy programming
:)

/silvastre
Fantastic! :friends: :bow:

I am grateful you took the time to post your suggestion. I replaced the send key logic I had implemented which was not nearly as clean. See Below snippet. Keep in mind I was artificially selecting an image tagged as "picture"\"fake" to gain access to the menu items needed.



Sub AACompressImages()
Dim oSh As Shape
Dim lCurrSlide As Long
Dim SlideName
Dim intCurrSlide
Dim oSlide As Slide
On Error GoTo errhandler

Set oSlide = ActivePresentation.Slides("chartmanage")
lCurrSlide = oSlide.SlideIndex
ActiveWindow.View.GotoSlide lCurrSlide
Set oSh = Module3.GetShapeTaggedWith("picture", "fake", oSlide)
If Not oSh Is Nothing Then ' we found it
ActivePresentation.Application.DisplayAlerts = ppAlertsNone
oSh.Select
SendKeys "%oi", False
SendKeys "%m", False
SendKeys "aw{ENTER}{ESC}{ESC}", True
Else
MsgBox "Image Not found"
End If

Exit Sub
errhandler:
MsgBox "Error: " & Err.Number & " " & Err.Description

End Sub


Your code works flawlessly and also eliminates some other hoops I was jumping through. The compress images challenge has been a relative "hack" compared to other functionality I am delivering. This will serve to significantly clean up that process.

Thank you very much!

If I can humbly offer up any assistance with some issues I have worked through please feel free to post.