azizrasul
Well-known Member
- Joined
- Jul 7, 2003
- Messages
- 1,304
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
I am trying to figure out what the vba code would be to determine whether a PPTX or DOCX files are password protected. The following (for PPTX file) isn't working but it's what I have so far. I hope that if I get error 1004 then it's not password protected but if it reaches the end then it is.
It doesn't like the Password:= bit. However similar code for Excel files work.
I don't want the password dialog box to appear, I just want a value of True or False to be returned.
It doesn't like the Password:= bit. However similar code for Excel files work.
I don't want the password dialog box to appear, I just want a value of True or False to be returned.
VBA Code:
Dim objPowerPoint As Object
On Error GoTo ErrorHandler
Set objPowerPoint = CreateObject("PowerPoint.Application")
With objPowerPoint
.Presentations.Open FileName:=strPowerPointFile, Password:="", ReadOnly:=msoFalse, untitled:=msoTrue, withwindow:=msoFalse
.Quit
End With
Set objPowerPoint = Nothing
PowerPointFileProtection1 = False
ErrorHandler:
If Err.Number = 1004 Then
PowerPointFileProtection1 = True
End If
Last edited: