In order to make sure that the important information can't be revealed, we may encrypt a Word document by giving it a complicated password. The Word protection function is very powerful that it is difficult to get the encrypted document without password. However, sometimes, we may forget the password if it is too complex or we can't use the protected Word document for a long time.

How to Decrypt Word Document by Using Spire.Doc

In Spire.Doc, you can simply use document.LoadFromFile method to decrypt a word document. When you load a encrypted document, you should give three parameters to decrypt it: Document name, Document format and the password. With the password, you can decrypt the document. Following example is about decrypting a word document. In this example, the "Sample.doc" is a file which is encrypted. And the password is "test".
The following code can show the method to decrypt Word:
[C#]

using Spire.Doc;
using Spire.Doc.Documents;

namespace Decrypt
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create word document
            Document document = new Document();
           
            //Load a file with password
            document.LoadFromFile("Sample.doc", FileFormat.Doc, "test");
           
            //Save doc file.
            document.SaveToFile("Sample.doc", FileFormat.Doc);

            //Launch the MS Word file.
            System.Diagnostics.Process.Start("Sample.doc");
        }
    }
}
         

[Visual Basic]

Imports Spire.Doc
Imports Spire.Doc.Documents

Module Module1

    Sub Main()
        'Create word document
        Dim document As New Document()

        'Load a file with password
        document.LoadFromFile("Sample.doc", FileFormat.Doc, "test")
       
        'Save doc file.
        document.SaveToFile("Sample.doc", FileFormat.Doc)
       
        'Launch the file.
        System.Diagnostics.Process.Start("Sample.doc")
    End Sub
End Module