Can a PDF File's Protected View be Removed with VBA Code

gdunn59
gdunn59 used Ask the Experts™
on
I have some VBA Code in MS Access that grabs a PDF from an email in Outlook.  When I open these PDFs they show that they are in "Protected View" mode.   Next to this message is a "Enable All Features" button that removes the protection.

My VBA code loops through the PDF document and grabs the text from each field and then puts it in a table in Access.  Because the PDFs are protected, it's unable to grab any of the text from the PDF.

Is there a way with VBA Code to remove the "Protected View" mode from the PDFs once it is open, and prior to my VBA Code running?

Here is my VBA code:
Function GetFileText(strFilePath As String) As String
'IAC objects
Dim gPdDoc As Acrobat.CAcroPDDoc
Dim gAvDoc As Acrobat.CAcroAVDoc

'variables
'Dim gPDFPath As String
Dim sName As String
Dim lNum As Integer

'Initialize Acrobat by creating App object
Set gApp = CreateObject("AcroExch.App")

'Set AVDoc object
'gAvDoc = gApp.GetActiveDoc
Set gAvDoc = CreateObject("AcroExch.AVDoc")

' open the PDF
If gAvDoc.Open(strFilePath, "") Then
    gApp.Show
    'Set PDDoc object and get some data
    Set gPdDoc = gAvDoc.GetPDDoc
    lNum = gPdDoc.GetNumPages
    sName = gPdDoc.GetFileName
    GetFileText = Acro_GetPageText(strFilePath, gPdDoc, gAvDoc)
End If

End Function

Open in new window

Thanks,
gdunn59
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
I don't think VBA can manipulate a PDF to that level...

If it could, then "protected" would not mean much...
;-)

But lets see what other experts may suggest.

Author

Commented:
Jeffrey Coachman,

That's what I was wondering.

Thanks!
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
oK, ...lets see if another Expert may have a suggestion
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Software & Systems Engineer
Commented:
You could bypass it by using some of the utilities that are circulating in the Internet and calling it by Access..unlock the PDF and repeat the process..i have found this post here that you could utilize with some tweaking.

Author

Commented:
John,

I noticed that the software in your post is available for download.  Only problem, our company doesn't allow us to download anything.

I've also got the IT people here at work looking into why it isn't working now, because it wasn't an issue prior to upgrading to Windows 10 and MS Access 2016.  These PDF documents were protected before also, but it worked.

Thanks,
gdunn59
John TsioumprisSoftware & Systems Engineer

Commented:
Trying to bypass limitations without using extra tools is near impossible

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial