Modify Password of Encrypted PowerPoint Document in C#, VB.NET

Sometimes we may need to re-encrypt the document whose password has been or is at the risk of being leaked out. This article will show you how to load an encrypted PowerPoint document and modify its password using Spire.Presentation.

Code Snippet:

Step 1: Create an object of Presentation class.

Presentation presentation = new Presentation();

Step 2: Load an encrypted PowerPoint document into the Presentation object.

presentation.LoadFromFile("Encrypted.pptx",FileFormat.Pptx2010, "oldPassword");

Step 3: Remove the encryption.

presentation.RemoveEncryption();

Step 4: Protect the document by setting a new password.

presentation.Protect("newPassword");

Step 5: Save the file.

presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);

Full Code:

[C#]
using Spire.Presentation;
namespace ModifyPassword
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("Encrypted.pptx", FileFormat.Pptx2010, "oldPassword");

            presentation.RemoveEncryption();
            presentation.Protect("newPassword");

            presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);

        }
    }
}
[VB.NET]
Imports Spire.Presentation
Namespace ModifyPassword

	Class Program

		Private Shared Sub Main(args As String())
			Dim presentation As New Presentation()
			presentation.LoadFromFile("Encrypted.pptx", FileFormat.Pptx2010, "oldPassword")

			presentation.RemoveEncryption()
			presentation.Protect("newPassword")

			presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)

		End Sub
	End Class
End Namespace