Word Decryption is relative to Word encryption, which is one method to protect important documents. As is known, people need to have the correct password to open one encrypted Word document. This process is also called decryption.
In this post, I want to introduce a method about how to decrypt word with C#/VB.NET.
In my example, I have a document which has been encrypted with password. The password is 123456. What I will do is to decrypt this document.
Note: I use the .NET Word component, Spire.Doc for .NET, which specializes in operating Word documents, to meet my requirement more easily and quickly. Therefore, if you want to use the following code, please add Spire.Doc for .NET dll file as reference.
Detailed Steps Shown as Following:
- Load the encrypted file from computer by using document.LoadFromFile() method. Generally speaking, I just need to pass one parameter which is filename to this method. However, now, I need to send three parameters to this method for decrypting this document directly. The three parameters are file name, file format and password string.
- Save the decrypted document with another name and launch this new document.
static void Main(string args)
//Load and Decrypt
Document document = new Document();
document.LoadFromFile(@”E:\work\Documents\welcome.docx”, FileFormat.Docx, “123456”);
//Save and Launch
Friend Class Decryption
Shared Sub Main(ByVal args() As String)
‘Load and Decrypt
Dim document As New Document()
document.LoadFromFile(“E:\work\Documents\welcome.docx”, FileFormat.Docx, “123456”)
‘Save and Launch
After running, Document Welcome.docx will be shown without entering password.
Related Post: How to Encrypt Word Document – C#/VB.NET