【问题标题】:loop through folder of PDF files循环浏览 PDF 文件的文件夹
【发布时间】:2015-06-30 17:49:11
【问题描述】:

我想循环浏览一个 PDF 文件文件夹并将文件插入到 word 文档的相应文本框中。

我在网上找不到太多关于它的信息,但我尝试在循环遍历 excel 文件的文件夹时对我的代码进行建模...我没有尝试让它插入 PDF,但我正在尝试解决这个问题第一的。顺便说一句,我有 Adob​​e Reader 而不是 Adob​​e Professional,如果有帮助的话。

我调试了代码,错误在Set fromPDF = AcroExch.PDDoc.Open(sPath & sFile)...

任何帮助将不胜感激。

Sub UseTextBox()

Dim reportDoc As Object
Dim str As String
Dim tag As String
Dim pdfName As String

Set reportDoc = ActiveDocument
MsgBox reportDoc

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False


'match PDF to figure and insert
Set SelectFolder = Application.FileDialog(msoFileDialogFolderPicker)
    With SelectFolder
        .Title = "Select Directory"
        .AllowMultiSelect = False
        If .Show <> -1 Then GoTo ResetSettings
        sPath = .SelectedItems(1) & "\"
    End With



sFile = Dir(sPath & "*pdf")
Do While sFile <> ""
    Set fromPDF = AcroExch.PDDoc.Open(sPath & sFile)
    pdfName = sFile


For Each objShape In reportDoc.Shapes
    If objShape.Type = msoTextBox Then
        str = objShape.TextFrame.TextRange.Text
        If InStr(str, "(") > 0 Then

            tag = BetweenParentheses(objShape.TextFrame.TextRange)
            MsgBox tag
        End If
    End If
Next objShape
sFile = Dir
Loop

ResetSettings:
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False



End Sub

【问题讨论】:

    标签: excel vba pdf


    【解决方案1】:

    您在哪里创建 AcroExch 对象?我认为这可能是您的问题。

    你可能需要这样的东西:

    Set MyObject = CreateObject("AcroExch.PDDoc")
    

    【讨论】:

    • 原来我只有 Adob​​e Reader,它的 OLE 功能有限。似乎没有 Adob​​e Acrobat,我将无法循环浏览 PDF 文件的文件夹?我将 PDF 作为对象插入并记录了宏,这很好....但是因为我有阅读器,这是否意味着我将无法自动化该过程? @Ryan Wildry
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-20
    • 2015-12-07
    • 2020-09-05
    • 1970-01-01
    • 2012-05-09
    • 1970-01-01
    相关资源
    最近更新 更多