Extracting font information from a TextRange

Y

YourManInJapan

I need to extract the font information from a Publisher TextRange. For
example, if I have a sentence in mixed italics: "/This is italic/ and this is
not", I need to find out the start and end position of the italicised text.
Is there some functionality equivalent to the "Runs" implemented by the
Office.Core.TextRange2 interface, or do I have to go through character by
character?

I feel like I must be missing something very simple here. Any help would be
greatly appreciated!
 
C

Cory

Can you check the state of the Italics button? I am not on a machine that
had puiblisher on it at the moment, but if you can somehow get a cursor in
the text frame you could move it and check the state of the
italics/underline/bold toolbar buttons. Otherwise, you could create an
instance of Word, copy/paste the shapes text into the document, and move
about in there leaving the Word application.Visable = False so that it is all
transparent. Word has cursor and selection movement methods and I am sure
that it can evaluate the use of font modifiers there at least in a
True/False/Mixed capacity. If not, then I don't know what you could do.

Cory
 
Y

YourManInJapan

Thanks for your repy, Cory.

You can interrogate the TextRange.Font object to find the font properties of
a TextRange, the problem lies not with accessing the information, but
accessing it in a performant fashion. I can check character 1, then 2, 3 and
so on, but this extreemly slow. I can also check the entire TextRange or any
portion of it, but with little granularity; the TextRange.Font.Italic
property will return true, false or mixed, not the start and end positions of
the italicised text. In this way it somewhat mirrors the state of the Italic
button as suggested in your post.

The key objective here is to find the begining and end of runs of
consistently formatted text in a perfomant way.
 

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