ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 名课 - Power BI数据分析与可视化实战 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
Python自动化办公应用大全 Excel 2021函数公式学习大典 Kutools for Office 套件发布 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
楼主: a945kl999

[求助] 如何用VBA 控制Acrobat打开PDF文件

[复制链接]

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-12 23:16 | 显示全部楼层

是不是Reader版啊,上传完整的Excel file上来啊

急死人啊

我还是同样的错误信息

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-13 09:26 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

我装了Adbobe 7 professional 后 的确可以运行,但是为什么Adobe acrobat 7.0 reader不能啊,我公司用的就是这版本,

真是见鬼阿!有没有哪个高手可以解决这问题啊? 3Q

在线等阿

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-13 09:29 | 显示全部楼层

当运行到 PDFApp.Open filename,有错误:ActiveX component can't create object

------------------------------quoted------------------------------------------

Sub CTRLPDF()

Dim PDFApp As New Acrobat.AcroPDDoc
Dim filename As String

filename = "D:\test.pdf"

 PDFApp.Open filename

    MsgBox PDFApp.GetFileName
End Sub

------------------------------------------------------

绑定见下

-------------------------------------------------------
我在VBE里

Tools->Reference->browser

选中

->C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.DLL

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-13 09:31 | 显示全部楼层

有没有其他解决方法,可以早期绑定或其它?

请高手出招

TA的精华主题

TA的得分主题

发表于 2006-9-13 11:00 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-13 11:55 | 显示全部楼层

Can you copy the solution for me as there have limitations for outsider.

TA的精华主题

TA的得分主题

发表于 2006-9-13 11:59 | 显示全部楼层
asked by howardching on 08/16/2005 01:25AM PDT

Can I use Access VBA Code to call the Acrobat Reader or any other tools to open pdf file and capture the data inside the file?
---------------------
Comment from Sayedaziz
Date: 08/16/2005 01:34AM PDT
Comment

Check if it suits :

Private Sub Command1_Click()
 Dim RetVal
 RetVal = Shell("Complete Path for Acrobat " & "FilenameCompletepath", 1)
End Sub

for example :

RetVal = Shell("C:\Program Files\Microsoft Office\OFFICE11\Excel.EXE " & "C:\Folder.xls", 1)

The above will run Application Excel and will open file Folder.xls in C: drive

Aziz

Comment from howardching
Date: 08/16/2005 01:36AM PDT
Author Comment

I need to capture the data from the pdf file, not just to open it.

Comment from Arthur_Wood
Date: 08/16/2005 04:38AM PDT
Comment

the Adobe Acrobat Reader will NOT do what you are asking.  The Reader is a FREE tool, provided by Adobe, to allow non-licensed 'users' to format and DISPLAY PDF files.  This does not provide the capability to open a pdf file and expose the internal structure of whatever is contained therein.  If you want to be able to get to the internal data, I need to purchase the FULL licensed version of Adobe Acrobat - not just the Reader.

AW

TA的精华主题

TA的得分主题

发表于 2006-9-13 12:00 | 显示全部楼层
Comment from jimhorn
Date: 08/16/2005 06:27AM PDT
Comment

The short answer is NO.  (redundant of above posts)

Acrobat Reader = Read-Only, you cannot access the content of the .pdf programmatically.  To do this you will need Adobe Acrobat Professional, which last time I checked runs around $449 US.

Hope this helps.
-Jim

Comment from DrB1309
Date: 08/16/2005 08:23AM PDT
Comment

this allows you to print PDF forms using automation for the free Acrobat Reader. There are other actions that the Reader supports in automation as well, but i can't recall if they are limited to save and print.
I think you can find them here: http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACReference.pdf



Public Function PrintPDFForms(prtFileName As String, prtDrive As String)
Dim AcrApp As Object
Dim acrDoc As Object
Dim acrPDDoc As Object
Dim ret As Long
Dim lngPage As Long

    Set AcrApp = CreateObject("AcroExch.App")
' uncomment if you want to see the Acrobat window
    'ret = AcrApp.Show()        
   
    Set acrDoc = CreateObject("AcroExch.AVDoc")
   
    acrDoc.Open "YourFileName",  "PDF Print"
    Set acrPDDoc = acrDoc.GetPDDoc
    lngPages = acrPDDoc.GetNumPages
    ret = acrDoc.PrintPages(0, lngPages - 1, 1, True, True)
       
   
    Set acrDoc = Nothing
    Set acrPDDoc = Nothing
    AcrApp.CloseAllDocs
    AcrApp.Exit
    Set AcrApp = Nothing

End Function

Comment from jimhorn
Date: 08/16/2005 08:36AM PDT
Comment

The Adobe Acrobat 7.0 Type Library, aka ArchExch in the above code, is not installed with Acrobat Reader, only Acrobat Professional.

Sorry dude.

Comment from DrB1309
Date: 08/16/2005 08:39AM PDT
Comment

I only have the Reader, not the professional. The above worked on my machine with that alone. Also on a user machine with Reader only.

Comment from DrB1309
Date: 08/16/2005 08:53AM PDT
Comment

Now I'm really confused. What is the name of the .tlb? ArchExch.tlb is not on my machine anywhere. i do have C:\Program Files\Adobe\Acrobat 7.0\Activex\Acropdf.dll

Comment from jimhorn
Date: 08/16/2005 08:59AM PDT
Comment

On my XP box it's C:\Program Files\Adobe\Acrobat 7.0\Acrobat\acrobat.tlb
On my W2K/O2003 box it's C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.dll.

Both have Adobe Acrobat Professional 7 installed.

I eyeballed another W2K/O2003 box and noticed that the Tools:Reference was missing, and assumed that it was because Pro was not installed.

\Reader\ would imply that it's installed with Reader.  Hmm....  


Comment from DrB1309
Date: 08/16/2005 09:14AM PDT
Comment

Yes, I have the AcroRd32.dll in that directory.
I can't find where i got the information to produce that code either, and it was only last week, well maybe two weeks ago.
I did find this:
http://www.adobeforums.com/cgi-bin/webx?127@288.VZFNemgDRNc.3@.ee6b2e6
Which suggests using DDE.
In any event, the things you can do are limited to display and print, and maybe go to a page. You can't copy the text out with automation.
I'll keep looking.

Comment from DrB1309
Date: 08/16/2005 09:25AM PDT
Comment

This is not where i found the information allowing me to write the code above. but it is germain.
http://forum.planetpdf.com/wb/default.asp?action=9&read=49375&fid=100#134101

And specifically this response:

"Again thank you everyone that assisted in helping with this answer. I was contacted by a senior representative at Adobe (Lori DeFurio) about this and she cleared up and confirmed all of the doubts I was having.

To start, she oplogized for the misinformation that I received when I called Adobe and gave me clarity on the SDK. Like aandi mentioned, you do need some form of Adobe Acrobat or Reader on the clients machine to be able to view PDF documents. The SDK is just a layer for the developer to utilze to view the PDFs.

Second, I (as the developer) only had Adobe Reader on my machine when infact I need to have Adobe Acrobat (the full version) on my PC inorder to use the SDK sample ActiveViewVB. The API's for this sample are geared for Acrobat (the full version).

Third, inorder to be able to allow the clients to use only the Adobe Reader I need to follow the examples for the AcrobatActiveXVB or the BasicIacOCXCS. These use ActiveX controls that are geared for the Acrobat Reader."

Accepted Answer from eagle1357
Date: 08/16/2005 09:31AM PDT
Grade: B
Accepted Answer

howardching:

If the pdf has text in it (not a scanned image of text), you can use XPdf to extract the text and open the resulting text file in your code. Get the tool here: http://www.foolabs.com/xpdf/ Usage is "pdftotext.exe -layout test.pdf"

I used this method for 2 years at my last job and didn't have a problem. XPdf will insert an ASCII 12 character for each page break, but that can easily be cleaned out. If you're worried about users seeing a DOS box, you can open it using the vbHide option.. Shell("c:\command.exe", vbHide).

If the PDF is an image file, then you're going to have more difficulty. Office 2003 includes some OCR software if you need that. Good luck.

Comment from eagle1357
Date: 08/16/2005 09:38AM PDT
Comment

Here is a link to pdftotext.exe without having to fish for it.. http://www.inforapid.org/se/xpdf.zip

Comment from howardching
Date: 08/16/2005 06:42PM PDT
Author Comment

I try "pdftotext.exe -layout file.pdf", but the file.txt is empty.

Comment from eagle1357
Date: 08/17/2005 09:11AM PDT
Comment

Then it sounds like your pdf file does not contain text. Can you select text in the PDF file using acrobat?

Comment from jimhorn
Date: 08/17/2005 09:13AM PDT
Comment

howardching - You may want to post a 20-point 'linking' question in the Acrobat TA, with the same question title, and copy-paste the URL from this question into that one.  I'm guessing that the average Acrobat expert would be better suited to answer your question then the average Access expert.

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-13 12:11 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2006-9-13 13:34 | 显示全部楼层

读完,咳,难道是没有办法在只有Reader的电脑用VBA控制Adobat Acrobat了吗?

用VB可以吗?

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2025-12-24 17:12 , Processed in 0.027843 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表