【问题标题】:Object does not support this property or method error对象不支持此属性或方法错误
【发布时间】:2018-01-29 13:29:37
【问题描述】:

我正在尝试将数据从 excel 复制到易出错的 PDF 表单。使用下面的代码,我打开易出错的表单并填充数据,我需要使用 varibale 'pr' 进行保存。 保存时抛出运行时错误

“对象不支持此属性或方法”

Dim fcount As Long
Dim sFieldName As String

Set AcrobatApplication = CreateObject("AcroExch.App")
Set AcrobatDocument = CreateObject("AcroExch.AVDoc")

If AcrobatDocument.Open("C:\Users\Desktop\Projects\Jan 2018\Excel to PDF\Test.pdf", "") Then
    AcrobatApplication.Show
    Set AcroForm = CreateObject("AFormAut.App")
    Set Fields = AcroForm.Fields
    fcount = Fields.Count    ' Number of Fields

    With ThisWorkbook.Sheets(1)
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

        For i = 2 To LastRow
            Fields("Enter county name").Value = Range("A" & i).Value
            Fields("Enter county served").Value = Range("B" & i).Value
            Fields("Parcel number").Value = Range("C" & i).Value
            pr = Range("C" & i).Value
            Fields("Property owner name").Value = Range("D" & i).Value

            fname = "C:\Users\Desktop\Projects\Jan 2018\Excel to PDF\docs\" & pr & ".pdf"

            If AcrobatDocument.Save(PDSaveFull, fname) = False Then
                MsgBox ("Cannot save the modified document")

            End If

        Next
    End With

Else
    MsgBox "failure"

【问题讨论】:

    标签: vba excel pdf


    【解决方案1】:

    Dim pr as String

    考虑到你只在这里使用它应该足够了:

    fname = "C:\Users\Desktop\Projects\Jan 2018\Excel to PDF\docs\" & pr & ".pdf"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 2011-02-14
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      相关资源
      最近更新 更多