使用excel中的VBA从.PDF(文件)扩展文件属性

时间:2016-09-14 21:48:30

标签: vba excel-vba pdf excel

我试图了解下面的问题... Bassicaly I列出excel表中的一系列文件,我也希望为每个文件添加标签。 这对于office文件来说不是问题,因为我使用" .BuiltinDocumentProperties(" Keywords")。值"。

然而,当谈到Pdf文件 我认为使用" .GetDetailsof()"会很简单。以便访问扩展属性。

嗯......出于某种原因,我得到了以下内容,

sValue = oDir.GetDetailsOf(oDir.Items, 18)

'Returns the "Date Modified"

当我使用

sValue = objFile.DateLastModified
'Returns the actual Value e.g. 09/11/2012 07:01:48

非常感谢任何意见或建议。

P.S.1我已经阅读了与扩展文件属性相关的Link。 我希望我能错过任何事情。

P.S.2为了能够为pdf文件添加值,我使用File Meta Data

1 个答案:

答案 0 :(得分:0)

以下是一些代码,概述了可用的属性以及如何访问它们。

改编自:http://windowssecrets.com/forums/showthread.php/157834-VBA-FileSystemObject-Properties-Dimensions-Size-and-Vertical-resolution

Sub GetDetails()
  Dim oShell As Object
  Dim oFile As Object
  Dim oFldr As Object
  Dim lRow As Long
  Dim iCol As Integer
  Dim vArray As Variant
  vArray = Array(0, 1, 3, 4, 18)


  Set oShell = CreateObject("Shell.Application")
  lRow = 1
  With Application.FileDialog(msoFileDialogFolderPicker)
    .Title = "Select the Folder..."
    If .Show Then
      Set oFldr = oShell.Namespace(.SelectedItems(1))
      With oFldr
        For iCol = 0 To 286
          Cells(lRow, iCol + 1) = .getdetailsof(.items, iCol)
        Next iCol
        For Each oFile In .items
          lRow = lRow + 1
          For iCol = 0 To 286
            Cells(lRow, iCol + 1) = .getdetailsof(oFile, iCol)
          Next iCol
        Next oFile
      End With
    End If
  End With
End Sub