I am trying to use a VBA module to open a protected PPTX file, unlock it, then edit and save as. I currently have all the script working if the file is not locked, but I have no clue as to how to unlock a PPTX file using VBA 7.1.
Here is the code that I use. I just need to know the VB code to unlock the pptx file:
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