Guide me how to encrypt a word in VB

Asked By 0 points N/A Posted on -
qa-featured

 

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?

SHARE
Answered By 0 points N/A #162333

Guide me how to encrypt a word in VB

qa-featured

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);

                   System.Diagnostics.Process.Start("Encryption.Docx")

           End Sub

     End Class

End Namespace

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

I hope this helps.

Related Questions