-
October 16th, 2012, 05:08 AM
#1
Compare Paragraph Styles
Hi,
I am writing a word document using C#. At some point, I have to see if a heading is already archived in word, so that I can skip writing it again. My problem is
1. I can not iterate through headings in a word document.
2. If I iterate through paragraph and try to compare if its heading is same Word.WdBuiltinStyle.wdStyleHeading1, it returns me an error that unboxing in this format is not possible.
Below is the code:
Code:
object headingStyle = Microsoft.Office.Interop.Word.WdBuiltinStyle.wdStyleHeading1;
foreach (Word.Paragraph para in mTdbDoc.Paragraphs)
{
Word.WdBuiltinStyle style = (Word.WdBuiltinStyle)para.get_Style(); //Error here
if (style.Equals(headingStyle))
if (para.Range.Text.StartsWith(aCompareString))
return para.Range.End;
}
return -1;
I do not want to do it with Syle.NameLocal because it differs on different machines depending on the word language.
Any hint will be helpful.
Regards
Ricky
-
October 17th, 2012, 03:22 AM
#2
Re: Compare Paragraph Styles
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|