R
RNG
Hello:
I’m automating Microsoft Word to parse a document and do a style
conversion. What my program does is the user defines a set of mappings of
styles let’s said StyleA maps to StyleB, StyleC maps to StyleD and so. Then
my program parses the whole document and every time it finds StyleA it
converts it to StyleB, etc.
The application is performing fine for mapping paragraph styles; the
problem is that to do character styles conversion I have to loop thru all the
characters in the document. That’s taking a very long time.
Basically what I’m doing in pseudo code is the following:
Foreach (Paragraph parag in document.Paragraphs)
{
for (int i = 1; i <= parag.Range.Characters.Count; i++)
{
if (Word.Style)
parag.Range.Characters.get_Style().NameLocal is mapped then
parag.Range.Characters.set_Style(mappedStyle)
}
}
Is there any way to accomplish what I’m trying to do more quickly?
I don’t think it matters, but I’m using C# and VSTO 2005.
Thanks in advance,
Ram
I’m automating Microsoft Word to parse a document and do a style
conversion. What my program does is the user defines a set of mappings of
styles let’s said StyleA maps to StyleB, StyleC maps to StyleD and so. Then
my program parses the whole document and every time it finds StyleA it
converts it to StyleB, etc.
The application is performing fine for mapping paragraph styles; the
problem is that to do character styles conversion I have to loop thru all the
characters in the document. That’s taking a very long time.
Basically what I’m doing in pseudo code is the following:
Foreach (Paragraph parag in document.Paragraphs)
{
for (int i = 1; i <= parag.Range.Characters.Count; i++)
{
if (Word.Style)
parag.Range.Characters.get_Style().NameLocal is mapped then
parag.Range.Characters.set_Style(mappedStyle)
}
}
Is there any way to accomplish what I’m trying to do more quickly?
I don’t think it matters, but I’m using C# and VSTO 2005.
Thanks in advance,
Ram