FINDING IMAGES IN DOCUMENTS

J

JJ

How can I search in VBA for images in word docs, headers and footers
which are not inline images? I have tried searching for ^g and it
doesn't find the one's which are not "in line". Any suggestions?
 
J

Jay Freedman

JJ said:
How can I search in VBA for images in word docs, headers and footers
which are not inline images? I have tried searching for ^g and it
doesn't find the one's which are not "in line". Any suggestions?

You haven't said what you want to do with them once you find them, so it's
hard to be specific. In general, you'd run a loop like this:

Dim oShp As Shape
For Each oShp in ActiveDocument.Shapes
' do something -- select, format, delete, etc.
Next oShp

Inside that loop, you can examine the value of oShp.Type to find out whether
it's an autoshape, a textbox, or something else, so you can be more exact
about which shapes you "do something" with.

If the document contains both floating and in-line shapes, you'll have to
handle them in separate loops because they're in separate collections.

Dim oILShp As InlineShape
For Each oILShp in ActiveDocument.InlineShapes
' do something -- select, format, delete, etc.
Next oILShp

The two types of shape objects have different properties and methods, so
what you can do with them differs.
 
J

JJ

Hi Jay

I actually want to delete them and replace them with another image. The
logo of the company has changed and there are two different logo's
(.gif or .jpg image) in some documents. 1 in the header (not inline
shape). I will replace that logo with a big new logo and 1 in the
footer (not inline shape) and I want to replace that one with a small
logo. I am going to try what you have offered me and will get back. Now
that I have made it more clear perhaps you have other ideas as well.
Thanx in the meantime.
 

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