首页 > 解决方案 > 如何通过 VBA 和 AVDoc 在 Excel 中编辑嵌入的 PDF?

问题描述

我想使用 VBA 编辑作为对象附加到我的 Excel 文档的 pdf 文件。

背景:由于我不想以 .zip 或其他方式共享这两个文件,并且没有每个人都有权访问的网络驱动器,因此我需要一个“万无一失”的解决方案。

pdf 文件包含一个表格(强制性),并将填写此 Excel 文档中的信息。如前所述,我已经有了将 pdf 文件存储在网络驱动器上的解决方案。

Dim file, new_name As String
Set AcroApp = CreateObject("AcroExch.App")
Set AvDoc = CreateObject("AcroExch.AVDoc")

'Open new PDF file
'Use local path
file = "C:\Users\992\Desktop\example.pdf"
new_name = "New_PDF_12092019"

If AvDoc.Open(Datei, Name) Then
AcroApp.Show
Set PDDoc = AvDoc.GetPDDoc()
Set jso = PDDoc.GetJSObject

'Get cart ID
jso.getField("Feld1").Value = CStr(ActiveSheet.Range("B12").Value)

'Get Project ID
jso.getField("Feld2").Value = CStr(ActiveSheet.Range("B14").Value)
...

我的问题是:有没有可能使用嵌入式对象 AcroExch.AVDoc

由于参数szFullPath需要打开文件的完整路径,我考虑获取对象的“路径”并使用它 - 但我不知道如何。已经尝试过了:https ://danny.fyi/embedding-and-accessing-a-file-in-excel-with-vba-and-ole-objects-4d4e7863cfff

也许有人可以帮助我。提前致谢!

标签: excelvbapdfadobe

解决方案


推荐阅读