Problem with .TextFrame.TextRange.Text

J

Jon Robertson

I'm accessing a Publisher document via COM Automation, and I'm having a
problem with Problem with .TextFrame.TextRange.Text for text frames.

Let's say there is a Publisher document, with a text frame, and the
text frame contains the word "Information". The text frame can be
resized so that the whole word doesn't show. For example, you could
resize the text frame so that only "Inform" showed. Yet, "Information"
is still there, because if you make the text frame larger again, you
see the rest of the word.

However, .TextFrame.TextRange.Text only returns the portion of the word
that is visible in the text frame. I've been unable to find a way to
retrieve the whole contents of a text frame when the text frame is
smaller than the contents.

I've tried setting TextRange.End and using TextRange.MoveEnd. Neither
have solved my problem.

Any suggestions would be greatly appreciated!
 
E

Ed Bennett

Jon Robertson said:
I'm accessing a Publisher document via COM Automation, and I'm having
a problem with Problem with .TextFrame.TextRange.Text for text frames.

Have you tried .TextFrame.TextRange.Story.TextRange.Text?
Once text enters the overflow area (i.e. no longer appears in the text box),
it is no longer classed as being within the TextRange returned for the
TextFrame, and so it will not appear there.
 
J

Jon Robertson

Ed said:
.TextFrame.TextRange.Story.TextRange.Text

Thank you, Ed! That solved it!

I have another question, while I'm at it. If I set the value of .Text,
then later retrieve it, Publisher puts a CR on the end of the text even
though I didn't put a CR on the end initially.

Also, if I manually examine the text in Publisher, there doesn't appear
to be a CR on the end.

It isn't a major issue. I now know to look for the CR and to strip it.
It's just annoying. :)

Thanks again Ed!
 
E

Ed Bennett

Jon Robertson said:
It isn't a major issue. I now know to look for the CR and to strip
it. It's just annoying. :)

If you go to the end of a text box in Publisher (press Ctrl-End), and press
Shift-Right, the paragraph mark at the end of the last paragraph becomes
selected.
There is always a paragraph mark at the end of a text box.

You can just use Left$(TextRange.Text, Len(TextRange.Text) - 1)

(Note that if you are iterating through text boxes looking for empty ones,
Len(TextRange.Text) will be 1, not 0, as empty text boxes always contain a
paragraph mark.
 

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