Cannot open any DOCX file

6 posts, 1 answers
  1. Paul
    Paul avatar
    102 posts
    Member since:
    Jun 2010

    Posted 10 Jan 2013 Link to this post

    If I open any DOCX file, I get an error saying the file is locked and cannot be opened.  This is definitely not true.

    I then pulled Telerik source code and ran.  I found that the error is in the Telerik.Windows.Documents.dll file.  The error is in Paragraph.cs.  The error is at line 409.  As you can see by the photo, the Levels only contains one item, yet it's trying to reference Item[1] which would be impossible.  Should be Item[0].

    I can attach a DOCX file if no one else has this issue.
  2. Answer
    Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 14 Jan 2013 Link to this post

    Hello Paul,
     
    The problem is that the paragraph is associated with a level of the list style that is missing. The question is why this level is missing and if the paragraph should be connected to this level.

    We would appreciate it if you could open a support ticket and attach the file in question, so that we can investigate the case. It would also help if you could give us more information on how you created the file.

    Looking forward to your reply.

    Kind regards,
    Mihail
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Tuo
    Tuo avatar
    20 posts
    Member since:
    Oct 2011

    Posted 21 Jan 2013 Link to this post

    Hello Telerik,
    I had the same problem with opening docx file containing custom list style.
      Add custom style:
          Telerik.Windows.Documents.Lists.DefaultListStyles.RegisteredStyles.Add("CustomListStyle", customListStyle);
     Using custom style:
          customDocList= new Telerik.Windows.Documents.Lists.DocumentList(Telerik.Windows.Documents.Lists.DefaultListStyles.RegisteredStyles("CustomListStyle"), doc)
          customDocList.Add(paragraph, level)

      Export document to Docx
           FormatProviders.OpenXml.Docx.DocxFormatProvider docxFormatter;
           docxFormatter.Export(doc);
     After exporting to docx, then it will have  that problem.

    Best,
    Tuo
        
  5. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 23 Jan 2013 Link to this post

    Hello Tou,

    The issue you have encountered is related to the way you add custom styles. There is a help article on the subject which will be useful for you. If you follow the approach for registering and applying a custom style outlined there, there must not be any problems with the export.

    Greetings,
    Mihail
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Tuo
    Tuo avatar
    20 posts
    Member since:
    Oct 2011

    Posted 28 Jan 2013 Link to this post

    Hi Mihail,
           I Copied the example provided here to test the Custom ListStyle by adding it programmatically.
           The way I did is as follows:
    ListStyle myListStyle = CustomListStyle.CreateCustomListStyle();  // copy the code from the example to generate ListLevels
    ListStyle customListStyle = this.richTextBox.Document.AddCustomListStyle(myListStyle);

          The problem is that the ListLevels is empty in the returned "customListStyle", .
          Is there any point missed? Thanks.
    Best,
    Tuo
          
         
  7. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 30 Jan 2013 Link to this post

    Hello Tuo,

    This is expected behavior. You already have a reference to your list style named "myListStyle"  and you can use it if you want to modify the style. If you want to apply the style pragmatically, you should read the section "Applying List Style Programmatically" from the help article you posted in order to understand how you can apply your custom list style to a paragraph.

    The logic is rather complex as it has compatibility with older types of list styles provided mainly from MS Word.

    I hope this is helpful!

    Greetings,
    Mihail
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready