Auto remove images on save (macro)?

A

Andy King

Hi,

I'm trying to work out how to automatically remove images in word docs on
save, or onclick of a macro on the toolbar.

The docs are being uploaded to an Intranet and have a logo in which is
taking up unessecary space and slowly the upload down.

Any ideas much appreciated!

Thanks,

Andy
 
J

Jay Freedman

Andy King said:
Hi,

I'm trying to work out how to automatically remove images in word docs on
save, or onclick of a macro on the toolbar.

The docs are being uploaded to an Intranet and have a logo in which is
taking up unessecary space and slowly the upload down.

Any ideas much appreciated!

Thanks,

Andy

The general solution is fairly complicated, because graphics can be
inline or floating, and may be in the main document body, in headers
or footers, in text boxes, ... Each of these cases needs some special
handling. If you can narrow down your requirements to one or a few
cases, it'll be easier to help.
 
D

Dave Neve

Hi

In view of what Jay said, what about using the option not to load graphics
into Word when the doc is opened?

I'm assuming of course that you can go from here and send the docs as such
by Intranet

My system is in French but in English, it'll be something like 'options'
'display' 'space for images' (in Word of course)


Hope this helps


Dave Neve
 
A

Andy King

Hi Jay and Dave,

Thanks for the prompt replies...

Jay:
The documents (think of them as soft letterheads) are very similar, the
image (logo) is floating "in front of text" and always in the same position.

Complicated sounds good to me! Have you got any example code?

I created the following macro:
-----------------
ActiveDocument.Shapes("Object 9").Select
Selection.Cut
-----------------
which handles it in a dodged up way, but would like some error handling,
i,e, if it exists then cut (delete) it but i don't know how to do that bit!?
:S


Dave:
Unfortunately that doesn't work as i would like as it to as it only hides
the images and doesn't actually remove them


Thanks,
Andy
 
C

Cindy M -WordMVP-

Hi Dave,
My system is in French but in English, it'll be something like 'options'
'display' 'space for images' (in Word of course)
Tools/Options/View, Picture placeholders :)

Cindy Meister
 
S

Suzanne S. Barnhill

But pictures will still print.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
J

Jay Freedman

Hi, Andy,

If your documents contain only one shape, or if there are more than
one floating image in the document and you want to remove all of them,
then use this code:

Dim ct As Integer
For ct = 1 To ActiveDocument.Shapes.Count
ActiveDocument.Shapes(1).Delete
Next ct

This doesn't need error handling -- if there aren't any shapes in the
document, the .Count value is zero and the statement in the loop body
doesn't execute.

If there are (or could be) more than one, and you need to leave all of
them in place except the logo, then you need some way to distinguish
the logo from all the others. Unfortunately, I don't think you can
count on the logo always being named "Object 9" -- Word assigns these
default names by some unpublished (and apparently illogical) method.
If you know that the logo is always the only shape anchored in the
first paragraph, or on the first page, we can work with that.
 
A

Andy King

Hi Jay,

This is more like it, thanks... though one tiny issue, "Shapes" removes all
text boxes too, is there a parameter for just images (i couldn't see it in
the dropdown helper so is this where we get to the "fairly complicated"
bit!)?

Thanks,
Andy
 
C

Cindy M -WordMVP-

Hi Andy,
Can we please concentrate on my question instead of Dave's suggestion!
<tsk> What's wrong with letting Dave know what the English translation
is of his menu commands? It could help him to help someone else,
someday, even if his suggestion isn't the answer YOU need.

Cindy Meister
 
C

Cindy M -WordMVP-

Hi Andy,
This is more like it, thanks... though one tiny issue, "Shapes" removes all
text boxes too, is there a parameter for just images (i couldn't see it in
the dropdown helper so is this where we get to the "fairly complicated"
bit!)?
Polishing Jay's suggestion, a bit:

Dim ct As Integer, shp as Shape
For ct= ActiveDocument.Shapes.Count To 1, Step -1
Set shp = ActiveDocument.Shapes(ct)
If shp.Type = msoPicture Then shp.Delete
Next ct

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
A

Andy King

Thanks for the suggestion but unfortunately it gives a systax error with the
ln:

For ct= ActiveDocument.Shapes.Count To 1, Step -1
 
A

Andy King

Ooooooooo... i love it how SOME people take text such the wrong way!

Chill, it's Friiiiiiiday, enjoy!
 
J

Jay Freedman

Andy King said:
Thanks for the suggestion but unfortunately it gives a systax error with the
ln:

For ct= ActiveDocument.Shapes.Count To 1, Step -1

Remove the comma.
 

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