converting groups to GIFs in situ

M

matthewgdodds

I'm in the process of writing a macro to reduce the size of powerpoint
files with embedded and/or linked excel charts.

Thanks to previous contributions to this forum I have the
ungroup.ungroup.regroup conversion of the charts to groups in place.
This reduces the presentation's size by a useful ~50%.

However, if I export as GIFs the charts from the individual excel files
and reconstitute the presentation, its size is reduced to ~4% of the
original. So conversion to GIFs is the objective.

I would like to be able to do this direct in the presentation by VBA.
However, the only way I have been able to do this is first to SELECT
the group, save its position coordinates, then use saveas so write a
GIF version of the group to disc, then delete the group, and finally
reinstate the original appearance by importing the just-created GIF.

I have a couple of objections to this approach.
1. I learnt the hard way in excel VBA that selecting things is best
avoided if possible; so can anyone help with a snippet that will allow
GIF creation from a group simply by reference to it (by index or name
or .. something), rather than necessitating its selection??
2. I would also prefer not to be writing the GIFs to disc - for the
same reason as I would prefer not to select the shapes - it all takes
time, and besides I'll have to delete them afterwards to tidy up (still
more time taken); so can anyone help with a wholly virtual approach
which can generate the GIF in memory (or to clipboard??) from which it
can be pasted back in place of the original group?

Thanks in advance for your suggestions
 
D

David M. Marcovitz

I guess the question is: how would you know which group you want to do
this to if you haven't selected it? Once you answer that, VBA can help
you. You can easily identify shapes (including groups) by name or index
number, but I think you are still going to want to select because...

For your second question, my first thought was that has to be impossible
(how can you convert something to a GIF without saving it first as a GIF)
without your own routines to do GIF conversion. However, I discoverd that
one of the options under Paste Special is to Paste as a GIF. So, if you
select the shape, cut it, and paste special as GIF, you should be all
set.

This procedure seems to work, except it moves the object to the wrong
place, but I'm sure it wouldn't be too hard to put it in the right place
by saving the Top and Left of the original and applying them to the newly
pasted object (which becomes the selection).

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
D

David M. Marcovitz

I suggested the Paste Special because he doesn't want to have to save the
picture/group as a file and then re-import it. I couldn't think of any
other way to do this. Does VBA have any built-in oShp.ChangeToGif method?
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
M

matthewgdodds

Actually folks, there's less of an issue here than I thought; I had
been using a 'for each' loop to process each shape on each slide,
identifying those that were embedded or linked OLE and downsizing them
using ungroup.ungroup.regroup. However, the ORDER in which the 'for
each' loop processes objects is rewritten when an object is changed in
this way .... consequently for a slide with 4 charts it would process
the first, the second, and then revisit the first (already converted),
and then the second (ditto), and move on to the next slide, leaving
charts 3 & 4 still as embedded OLEs. This understandably left a file
only ~50% reduced in size, and so considerably larger than the version
reconstituted using GIF versions of the individual charts.

Having recognised this odd behavior of the 'for each' structure I'm now
stepping backward through the shapes using i=shapes.count to 1 step -1
and all charts are converted. The result is that a 4M ppt comes down to
256k; lovely outcome.

Thanks for the suggestions.

M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top