Compare Paragraph Styles
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Compare Paragraph Styles

  1. #1
    Join Date
    Aug 2008
    Posts
    70

    Question 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

  2. #2
    Join Date
    Jul 2011
    Posts
    6

    Re: Compare Paragraph Styles

    How about method this post shows?

    http://janewdaisy.wordpress.com/2012...-with-cvb-net/

    Hope helpful!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center