使用VBA读取(已知)受密码保护的pdf

时间:2018-09-25 03:12:01

标签: vba pdf

我能够读取非密码保护的pdf的属性。 无论如何,有没有阅读(已知)受密码保护的pdf的这些属性?

请注意,我不想删除密码或修改pdf,我的任务只是读取属性。如果没有第三方软件,我比较喜欢excel和相应的pdf。

下面是我的代码的摘录。

Public Function ReadPDFMetaData2(ByVal sFile As String) As Variant

Dim metaData(3) As Variant
Dim oApp As Object
Dim oDoc As Object
Dim strFileName As String, strNumPages As Long, strPageMode As String
Dim strTitle As String, strSubject As String, strAuthor As String
Dim strKeywords As String, strCreator As String, strProducer As String, strApplication

Set oApp = CreateObject("AcroExch.App")
Set oDoc = CreateObject("AcroExch.PDDoc")

With oDoc
  If .Open(sFile) Then
  '-- try to insert PASSWORD HERE, unsuccessful
  'If .Open(sFile, PasswordDocument:="mypassWord") Then 
    strFileName = .GetFileName
    'Debug.Print strFileName
    strCreator = .GetInfo("Creator")
    'Debug.Print strCreator
    strProducer = .GetInfo("Producer")
    'Debug.Print strProducer
    .Close
  End If
End With

Set oDoc = Nothing
Set oApp = Nothing
metaData(0) = strFileName
metaData(1) = strCreator
metaData(2) = strProducer
ReadPDFMetaData2 = metaData

End Function

0 个答案:

没有答案