0

I am trying to unlock a protected PPTX file, edit and save as.

The script works if the file is not locked.

How do I unlock a PPTX file using VBA 7.1?

Sub UpdatePPT()
Dim oPPApp As Object, oPPPrsn As Object, oPPSlide As Object
Dim oPPShape As Object
Dim FlName As String
Dim desktopFolderPath As String
Dim cellData As String
Dim password As String


desktopFolderPath = CreateObject("WScript.Shell").specialfolders("Desktop")
password = "Password123"
cellData = Range("Input!E21").Value
   
Const ppSaveAsDefault = 11

'~~> Change this to the relevant file
FlName = (desktopFolderPath & "\BES RCA Files\BES RCA Template DO NOT EDIT.pptx")

'~~> Establish an PowerPoint application object
On Error Resume Next
Set oPPApp = GetObject(, "PowerPoint.Application")

If Err.Number <> 0 Then
    Set oPPApp = CreateObject("PowerPoint.Application")
End If
Err.Clear
On Error GoTo 0

oPPApp.Visible = True

'~~> Open the relevant powerpoint file
Set oPPPrsn = oPPApp.Presentations.Open(FlName)
''''

When I try to add the ::password:: as suggested, it gives me the following error:
Error when adding password

9
  • In VBA, the syntax is Presentations.Open ("fullpath\pptfilename::password::") Commented Mar 7 at 17:50
  • 1
    This isn’t VBScript, looks to be VBA. Commented Mar 8 at 6:02
  • True, VBA, not VBScript. It's tagged correctly and in the right place, but OP, you might want to edit the title. Commented Mar 8 at 15:35
  • @SteveRindsberg, I tried that and it did not work. Commented Mar 10 at 12:22
  • Please edit your original post to show us what you have now and quote any error messages you see when it runs. Commented Mar 11 at 17:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.