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#]
Presentation presentation = new Presentation();
presentation.LoadFromFile("Encrypted.pptx",FileFormat.Pptx2010, "oldPassword");

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

presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
[VB.NET]
Dim presentation As Presentation = New Presentation()
presentation.LoadFromFile("Encrypted.pptx",FileFormat.Pptx2010, "oldPassword")
 
presentation.RemoveEncryption()
presentation.Protect("newPassword")
 
presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)