Opening a password protected pdf.

Rasberry

Board Regular
Joined
Aug 11, 2002
Messages
195
Office Version
  1. 365
When I get to the line: pdfReader.Open(pdfFile,pdfPassword), it says wrong syntax and won't advance. Any suggestions?



Dim pdfFile As String
Dim pdfPassword As String

'Set the path to the PDF file
pdfFile = "I:\Securities\Cash Commitments & Projection\Downloads\PGPMessage_2023802"

'Set the password for the PDF file
pdfPassword = "Pain2023"

'Create an object variable
Dim pdfReader As Object

'Set the object variable to a new instance of the AcroPDF.PDFReader object
Set pdfReader = CreateObject("AcroPDF.PDFReader")

'Open the PDF file with the password
pdfReader.Open(pdfFile, pdfPassword)

'Do something with the PDF file

'Close the PDF file
pdfReader.Close()
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try this:
VBA Code:
Dim pdfFile As String
Dim pdfPassword As String

'Set the path to the PDF file
pdfFile = "I:\Securities\Cash Commitments & Projection\Downloads\PGPMessage_2023802"

'Set the password for the PDF file
pdfPassword = "Pain2023"

'Create an object variable
Dim pdfReader As Object

'Set the object variable to a new instance of the AcroPDF.PDFReader object
Set pdfReader = CreateObject("AcroPDF.PDFReader")

'Open the PDF file with the password
pdfReader.Open(pdfFile, Password:= pdfPassword)

'Do something with the PDF file

'Close the PDF file
pdfReader.Close()
 
Upvote 0
Try this:
VBA Code:
Dim pdfFile As String
Dim pdfPassword As String

'Set the path to the PDF file
pdfFile = "I:\Securities\Cash Commitments & Projection\Downloads\PGPMessage_2023802"

'Set the password for the PDF file
pdfPassword = "Pain2023"

'Create an object variable
Dim pdfReader As Object

'Set the object variable to a new instance of the AcroPDF.PDFReader object
Set pdfReader = CreateObject("AcroPDF.PDFReader")

'Open the PDF file with the password
pdfReader.Open(pdfFile, Password:= pdfPassword)

'Do something with the PDF file

'Close the PDF file
pdfReader.Close()
Thank you so much. That syntax did not work either. I am working in VBA, if that makes a difference.
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top