How to show simple ms word document in C# WPF application? RRS feed

  • Question

  • hi all.

    How to show simple ms word document in C# WPF application? With images and pdf files it is a simple, but I have no idea how to show docx or doc documents. Just show ... there is no need to edit it.


    Tuesday, June 2, 2020 2:42 PM

All replies

  • You can use Word Automation

    Many samples on Google, like : Word automation using C#

    Tuesday, June 2, 2020 2:45 PM
  • There is really no easy way, we have a complex process which reads a Word document from SQL-Server, feed it to Word and then in the WPF app monitor Word (not automation) to when it closes, grab the document contents and save back to the database.

    Otherwise for read only view look at the DocumentViewer with documents converted to .xps which gets the following.

    private void LoadButton_Click(object sender, RoutedEventArgs e)
        var fileName1 = Combine(AppDomain.CurrentDomain.BaseDirectory, "documentation.xps");
        var doc = new XpsDocument(fileName1, FileAccess.Read);
        documentViewer.Document = doc.GetFixedDocumentSequence();

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Tuesday, June 2, 2020 7:57 PM
  • Hi TakeshiKitano,
    I viewed your description and it is mostly related to WPF. So it is recommended to ask the questions in Microsoft Q&A forum and you can get more professional answer.
    Thank you for your understanding.
    Best Regards,
    Daniel Zhang

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, June 3, 2020 1:34 AM
  • You could integrate a DocViewer control into your application for displaying Word document. The following control enables you to display Word documents in winforms and wpf applications.


    • Edited by Jamesbn Wednesday, June 3, 2020 2:08 AM
    Wednesday, June 3, 2020 1:40 AM
  • code doesn't know "Combine" ... 
    Wednesday, June 3, 2020 6:03 AM
  • So finally I found code for Spire.Doc ... but it is only for WinForms ... and it is paid I think ... I tried similar ... GemBox.Document ... it works ... but it is also paid ... so I am looking for absolutly free version ... free to show word file ... 

    but thanks

    Wednesday, June 3, 2020 9:40 AM