Images in Object Model

D

dan.berich

Group - I have very little knowledge of VBA and an attempting to get
the following question answered. Where can an object (image, drawing,
sound...) be placed in a Word document (in text, header, footer,
background...)? I need to get proof of all areas within the container
an object can be placed, so I was looking at the object model for
guidance, but to little avail. It looks like anything can be placed
anywhere with InlineShape but I don't really know what I'm looking
at. If anyone can point me in the right direction I'm running into a
bit of a wall, I can't seem to be able to even ask the right question
of Google.

Regards,
Dan
 
D

Doug Robbins - Word MVP

I think an image can be placed just about anywhere - in-line with text, in
front of text, behind text and in a header, footer, table cell, etc, etc.

Perhaps you should tell us what you are trying to do.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
D

dan.berich

I am testing a filtering application that is supposed to look for,
extract and analyse images in an Office (word, excel, ppt)
application. I need to be able to create test documents with images
(and other objects for that matter) in ALL of the available places.
Furthermore, I need to be able to pragmatically prove that the objects
are in fact in all the available places. So, I was looking at the
Object Model to locate where I could place the objects, but I can't
seem to find a 'proof' level of understanding that I found all the
places to place an object.

regards
 
C

Cindy M.

Hi Dan
I am testing a filtering application that is supposed to look for,
extract and analyse images in an Office (word, excel, ppt)
application. I need to be able to create test documents with images
(and other objects for that matter) in ALL of the available places.
Furthermore, I need to be able to pragmatically prove that the objects
are in fact in all the available places. So, I was looking at the
Object Model to locate where I could place the objects, but I can't
seem to find a 'proof' level of understanding that I found all the
places to place an object.

With the Word (Office) object model(s) I guess the only way to do this
would be to look at what can "parent" the object in question. Both
InlineShapes and Shapes depend on a Range object, which you can access
like this:
Dim rng as Word.Range
Set rng = theInlineShape.Range
Set rng = theShape.Anchor

So, anything in a document that returns a Range can (at least
theoretically) contain an InlineShape or a Shape (in that this is where
the anchor is located).

In practice, with Shapes, it will depend to a certain extent on which
version of Word you're dealing with. In some earlier versions of Word it
wasn't possible to anchor a Shape in some kinds of ranges. But in the
most recent version no such restrictions occur to me, right off hand.

So, if your code works through all the ranges in a document, it should
be able to detect all images (InlineShapes and Shapes) and insert images
in all such places. To work through all document ranges, you need to
loop through the StoryRanges collection. The basic code structure for
doing so can be found here

http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm

I think the bigger problem for you is going to be figuring out all
possible StoryRanges for a (complex) document...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

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

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