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