Guide me how to encrypt a word in VB

Asked By 0 points N/A Posted on -


Hi, I have some important MS word files. I need them to encrypt in visual basic. So, can you please guide me how to encrypt a word in VB?

Answered By 0 points N/A #162333

Guide me how to encrypt a word in VB


Hi Kayla,

I will outline a few steps and code you can use to encrypt your MS word files in VB.Net.

  1. Load the document you want to encrypt from your computer.
  2. Use the method document.Encrypt() to encrypt your document. The method takes the password you choose to encrypt the document with as its argument.
  3. After that you can now save and launch the file.

Below is the VB.Net code for encrypting your document:

Import System

import Spire.Doc

import Spire.Doc.Documents

Namespace Encrypt_Word

      Friend Class Encryption

           Shared Sub Main(ByVal args()As String)

                   Dim document As New Document()

                   document.LoadFromFile("file path of your text file e.g D:workMy DocumentsEssay.Docx")

                   document.Encrypt("the password you will use e.g 124553")

                   document.SaveToFile("Encryption.docx", FileFormat.Docx);


           End Sub

     End Class

End Namespace

You can get the other implementations apart from VB.Net from here

I hope this helps.

Login/Register to Answer

Related Questions