J
jimi_hendricks
Hi,
I have a function which loops through all styles in the styles collection,
but now i want to extend it to capture all direct formatting as well. Is
there a neat (efficient) way of capturing all variations of direct formatting?
For info (if it helps!): i am developing a feature to allow users to flip
between the usual styled and formatted view of their document, and one which
essentially renders it as plain text. It is crucial that they be able to edit
text while in this plain mode, and they must be able to revert to the fully
formatted and styled mode when done.
For proper styles, i copy each style in use (e.g. Heading 3), give the copy
an obscure prefix (e.g. obscureprefix_Heading 3), base all such styles on
Normal, then use find replace to find all text which uses the original style,
and tell it instead to use the copied style. That way when i revert to the
usual mode, i just search for all text using a style beginning
'obscureprefix_' and replace it with the original style which then
reintroduces all the appropriate style properties. lovely.
Now i want to do a similar thing for direct formatting. So, i can't just
remove all direct formatting (which is tempting!), but i suspect i will have
to find each case of direct formatting, create a temporary style, e.g.
'temp_obscureprefix_bold, italic' (to save the properties in) then begin a
process similar to the above.
When reverting to the usual mode, i will need to do a bit more work to apply
direct formatting (as per the properties stored in the temp style) before
removing the style itself, to ensure the the document does truly revert to
the way it was before.
As you can see, the process is likely to become processor intensive unless
cases of direct formatting can be neatly captured and traversed in a loop.
Since direct formatting appears in the 'styles and formatting' pane as though
it were a style (but without actually being a style), Word itself must have
some way of identifying direct formatting easily, no?
Any help or pointers would be greatly appreciated.
Thanks for your time.
I have a function which loops through all styles in the styles collection,
but now i want to extend it to capture all direct formatting as well. Is
there a neat (efficient) way of capturing all variations of direct formatting?
For info (if it helps!): i am developing a feature to allow users to flip
between the usual styled and formatted view of their document, and one which
essentially renders it as plain text. It is crucial that they be able to edit
text while in this plain mode, and they must be able to revert to the fully
formatted and styled mode when done.
For proper styles, i copy each style in use (e.g. Heading 3), give the copy
an obscure prefix (e.g. obscureprefix_Heading 3), base all such styles on
Normal, then use find replace to find all text which uses the original style,
and tell it instead to use the copied style. That way when i revert to the
usual mode, i just search for all text using a style beginning
'obscureprefix_' and replace it with the original style which then
reintroduces all the appropriate style properties. lovely.
Now i want to do a similar thing for direct formatting. So, i can't just
remove all direct formatting (which is tempting!), but i suspect i will have
to find each case of direct formatting, create a temporary style, e.g.
'temp_obscureprefix_bold, italic' (to save the properties in) then begin a
process similar to the above.
When reverting to the usual mode, i will need to do a bit more work to apply
direct formatting (as per the properties stored in the temp style) before
removing the style itself, to ensure the the document does truly revert to
the way it was before.
As you can see, the process is likely to become processor intensive unless
cases of direct formatting can be neatly captured and traversed in a loop.
Since direct formatting appears in the 'styles and formatting' pane as though
it were a style (but without actually being a style), Word itself must have
some way of identifying direct formatting easily, no?
Any help or pointers would be greatly appreciated.
Thanks for your time.