如何使用 VBA 在 PDF 中搜索
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15655987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to search in PDF using VBA
提问by maximladus
Hi I am Rookie in VBA,
嗨,我是 VBA 新手,
Is it possible to search within PDF files using VBA? And return the searched target with the name of the file in which the search is matched?
是否可以使用 VBA 在 PDF 文件中进行搜索?并以匹配搜索的文件名返回搜索到的目标?
To give you a better understanding what I do: I have a macro that goes on web page (http://cetatenie.just.ro/ordine/articol-11/) loops through the hyperlinks and downloads the matching criteria files (PDF). Now I need to search within them a name and surname (i.e. BLANARI VITALIE) and know in which file/doc it is published.
为了让您更好地了解我的工作:我在网页上有一个宏 ( http://cetatenie.just.ro/ordine/articol-11/) 通过超链接循环并下载匹配的标准文件 (PDF) . 现在我需要在其中搜索一个名字和姓氏(即 BLANARI VITALIE)并知道它是在哪个文件/文档中发布的。
The only idea that come into my head is to import data but than again the excel file will get too huge.
我脑子里唯一的想法是导入数据,但同样的,excel 文件会变得太大。
Please help!
请帮忙!
回答by Our Man in Bananas
if you have Acrobat Professional installed you can use the Automation (Acrobat.AcroPDDoc) and query the Postscript
如果您安装了 Acrobat Professional,您可以使用自动化 (Acrobat.AcroPDDoc) 并查询 Postscript
Here is an example I found for you (by searching on Google):
这是我为您找到的示例(通过在 Google 上搜索):
get the data from PDF file into Excel sheet(s) or text file(s)
从 PDF 文件中获取数据到 Excel 工作表或文本文件中
to use this code, you need the below References:
要使用此代码,您需要以下参考资料:
- AcroPDFLib
- Acrobat
- AcroPDFLib
- 杂技演员
on my pc they are in:
在我的电脑上,它们位于:
- AcroPDFLib: C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll
- Acrobat: C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.dll
- AcroPDFLib: C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\AcroPDF.dll
- Acrobat: C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.dll
if you can't find them in your VB Editor References dialog, or by searching for in C:\Program Files\Adobe, then you don't have the necessary components installed on your pc to do it the easy way
如果您在 VB Editor References 对话框中找不到它们,或者在C:\Program Files\Adobe 中搜索,那么您的电脑上没有安装必要的组件来轻松完成
The hard wayis to strip the PostScript and read it into variables then search the variables!
该硬盘的方式是剥离PostScript和读入变量然后搜索变量!
HTH
HTH
Philip
菲利普