Getting all the text from a set of inline shapes.

S

Simon Blake

Hi, I am having trouble finding a way to get the text from a set of inline
shapes... I can do this no problem under powerpoint, but word's shape model
appears to be different... (ie HasTextFrame is missing etc)
When I have tried to use the range option I just get a null back... Has
anyone else done this before (word2k3)

For Each myPic in appWord.ActiveDocument.InlineShapes

shapeText = .....

Next myPic

Thanks in advance
Simon
 
S

Simon Blake

Unfortuantly the document is 350+ pages, and has an inline shape on every
page that I am converting to a different format. I can grab the shape and
convert it to a jpeg but I need to also grab the text as an "alt text" type
format as well. I can right click, choose edit and then select/move the text
around so it must be an object somewhere in the shape.

Simon
 
H

Helmut Weber

Hi Simon,

in case you are talking about WordArt-inlineshapes,

you get their text with:

MsgBox ActiveDocument.InlineShapes(1).AlternativeText

if automating is your problem, ask again.
 
S

Simon Blake

Hi, yes this is over automation, the alternativetext is also comming back
blank. The shapes themselves contain a mix of images and editable text and
I'm attempting to grab them from VB, the code below saves them to jpeg files
no problem, but I also need to grab the text content as well so that the
"images" become search-able by adding the text to a database.
I've tried just using .ActiveDocument.Shapes, but then it does nothing as
the .count is 0

(Assume appWord contains a successfully loaded word file)

For Each MyPic In appWord.ActiveDocument.InlineShapes
MyPic.Select
appWord.Selection.Copy

strFileName = CStr(i) & "_hi.bmp"
Call SaveClipBoardToJpeg(strFileName)

' Need to get the shape's text and save that here...

i = i + 1

Next MyPic

Simon.
 
H

Helmut Weber

Hi Simon,
The shapes themselves contain a mix of images and editable text and
For Each MyPic In appWord.ActiveDocument.InlineShapes

you first have to get your head around,
whether your are talking of INLINESHAPES or SHAPES.

At least I can't think of an inlineshapes containing
text other than wordart-inlineshapes.
 
S

Simon Blake

Helmut,

They definately appear to be inline shapes, I have triple checked the .count
value for both shapes and inlineshapes, shapes = 0, inlineshapes = 656... I
then fired up word and had a look at one of these, the are basically a
"canvas" (word terminology) that contain "text box" elements and also images.
- I know, seems odd! I've tried running a .converttoshape on them, and that
gives an ole automation error on a good number of them. The shapes themselves
seem to have been oddly put together with a large number of text boxes, (ie
in some cases a text box for each word) so I know I have to iterate through a
collection inside the shape... I've done this for powerpoint quite easily
but word's shape model is totally different.

Simon.
 
H

Helmut Weber

Hi Simon,

you may send me the doc or a part of it,
an I'll see what I can do.

if I succeed, you'll here from me.
Use both addresses.

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
"h.weber" & chr(64) & "mi-verlag.de"
Word 2002, Windows 2000
 
H

Helmut Weber

Hi Simon,

well, that's a real tough one.
Yes, the pictures are inlineshapes.
Though, "edit picture" converts them to shapes.

I thought about transferring them to Powerpoint,
and processing them there,
like in this thread,
where imbedded powerpoint presentations
where changed from within word.
http://groups.google.de/group/micro...ut+author:Weber&rnum=1&hl=de#4c0f4116b50478d2

But I can't get it to work.
It seems, after the first workaround for the first bug
there is always another one.

Really sorry.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jonathan West

Simon Blake said:
Hi, I am having trouble finding a way to get the text from a set of
inline
shapes... I can do this no problem under powerpoint, but word's shape
model
appears to be different... (ie HasTextFrame is missing etc)
When I have tried to use the range option I just get a null back... Has
anyone else done this before (word2k3)

For Each myPic in appWord.ActiveDocument.InlineShapes

shapeText = .....

Next myPic

Thanks in advance
Simon

Hi Simon

I suspect that what you are trying to do is impossible.

A Shape (floating) has a TextFrame property, which in turn has a HasText
property, which returns True or False depending on whether the shape has
text.

However a shape that is a compound graphic (e.g. an inserted EMF file) with
a mixture of text and graphics will return False for this property. Only
textboxes and other simple shapes created using the drawing toolbar and to
which text has then been added will have their HasText property as True.

InlineShapes don't under any circumstances have a TextFrame property. if you
convert an InlineShape to a Shape, the TextFrame.HasText property will (as
far as I know) *always* be false.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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