从MS Access填写PDF表格 [英] Fill a PDF Form from MS Access

查看:120
本文介绍了从MS Access填写PDF表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此处上找到了一条帖子如何从MS Access中填充可填充PDF。

I found a post on here on how to fill a fillable PDF from from MS Access.

这是用于填充可填充PDF的Visual Basic代码。我一直在使用Excel来执行此功能,并且想将数据库迁移到Access并仍然保持相同的功能。我已经想出了如何将我的VB代码添加到按钮上,但是当我单击它时给了我错误。

It is a Visual Basic code for filling out a fillable PDF. I have been using Excel to perform this function and would like to migrate my database to Access and still keep the same functionality. I have figured out how to add my VB code to the button but when I click it gives me and error. Any help that can be giving would be greatly appreciated.

我有Adobe Acrobat X Pro和MS Access2010。我的PDF文件是用Word创建的,然后转换为PDF文件,我知道我所有的字段名称,因为我创建了它们。 PDF文档另存为c:\CX.pdf,共有9页,文档中字段名称的示例包括:工厂名称,站点位置,安装者或所有者。我的MS Access数据库字段的名称相同。

I have Adobe Acrobat X Pro and MS Access 2010. My PDF files was created in word and then converted to a PDF file, I know all my field names because I created them. The PDF document is saved as c:\CX.pdf, it has 9 pages, some examples of field names on the document are: "Plant Name", "Station Location", "Installer or Owner". My MS Access Data Base Fields are named the same.

Option Compare Database

Private Sub Command105_Click()

Dim FileNm, gApp, avDoc, pdDoc, jso

FileNm = "c:\CX.pdf" 'File location
Set gApp = CreateObject("AcroExch.app")

Set avDoc = CreateObject("AcroExch.AVDoc")
If avDoc.Open(FileNm, "") Then
    Set pdDoc = avDoc.GetPDDoc()
    Set jso = pdDoc.GetJSObject

    jso.getField("CX[0].Page1[0].Plant_Name[0]").Value = "Plant_Name"
    jso.getField("CX[0].Page1[0].Station_Location[0]").Value = "Station_Location"
    jso.getField("CX[0].Page1[0].Installer_or_Owner[0]").Value = "Installer_or_Owner"
    pdDoc.Save PDSaveIncremental, FileNm 'Save changes to the PDF document
    pdDoc.Close
    End If
'Close the PDF; the True parameter prevents the Save As dialog from showing
avDoc.Close (True)

'Some cleaning
Set gApp = Nothing
Set avDoc = Nothing
Set pdDoc = Nothing
Set jso = Nothing

End Sub

这给了我一个错误找不到对象,现在没有给我一个错误,但是它仍然没有写入PDF。

It was giving me the error "Object not found", now it's not giving me error but it's still not writing to the PDF.

推荐答案

这有点老了,但从长远来看对我有帮助。我确实找出了问题所在。 找不到对象意味着代码无法找到PDF字段,因此您不能为 getFeild()返回的对象分配任何内容。造成这种情况的最可能原因是该字段的路径不正确。尝试仅输入字段名称,您可能需要将数据导出到FTF文件并在记事本中读取文件以找到字段名称。

This is a bit old but it helped me in the long run. I did figure out what was wrong. "Object not found" means that the code cannot find the PDF field and therefore you can not assign anything to the object that "getFeild()" returns. The most likely culprit is that the "path" to the Field is incorrect. Try just putting the field name and you may need to export the data to a FTF file and read the file in notepad to find the field name.

字段名称看起来像

T/(FeildName)v/(FeildValue)

实际上返回了对象之后,您就可以为其分配一个值。

Once the object is actually being returned you'll be able to assign it a value.

这篇关于从MS Access填写PDF表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆