LER TEXTO DE PDF

CARLOSCOUTO 31/01/2014 17:26:27
#434037
Alguem me pode ajudar a ler um ficheiro pdf e escrever dentro do excel mas só com vba?

estou a fazer assim

Private Function ConvFicheiro(ficheiropdf As String)
Dim fso As FileSystemObject
Dim fsoArquivoPdf As Object
Dim fsoArquivo As File
Dim FileTXT As TextStream
Set fso = New FileSystemObject
Set fsoArquivoPdf = CreateObject([Ô]AcroExch.PDDoc[Ô])
fsoArquivoPdf.Open ActiveWorkbook.Path & [Ô]\Import\[Ô] & ficheiropdf & [Ô].pdf[Ô]
Set FileTXT = fso.OpenTextFile(ActiveWorkbook.Path & [Ô]\Import\[Ô] & ficheiropdf & [Ô].txt[Ô], ForWriting, True)
Set thePage = fsoArquivoPdf.AcquirePage(0)
Set thePageSize = thePage.GetSize
Set theRect = CreateObject([Ô]AcroExch.Rect[Ô])
theRect.Left = 0
theRect.Right = thePageSize.x
theRect.bottom = 0
theRect.Top = thePageSize.y
Set theSelect = fsoArquivoPdf.CreateTextSelect(0, theRect)
For i = 0 To theSelect.GetNumText - 1
theText = theText & theSelect.GetText(i)
Next
FileTXT.Write (theText)
FileTXT.Close
fsoArquivoPdf.Close
Set fso = Nothing
Set fsoPasta = Nothing
Set fsoArquivo = Nothing
Set fsoArquivoPdf = Nothing
End Function

mas quando vou para o computador da empresa ele dá erro [Ô]não é possivel criar objecto[Ô] na linha:
Set fsoArquivoPdf = CreateObject([Ô]AcroExch.PDDoc[Ô])


abraço
CARLOSCOUTO 01/02/2014 13:08:13
#434048
e esta dá perfeitamente


Sub Shell_Copy_Paste()

Dim o As Variant
Dim wkSheet As Worksheet

Set wkSheet = ActiveSheet

o = Shell([Ô]C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe C:\Users\Victor Lan\Documents\sample.pdf[Ô], vbNormalFocus)

Application.Wait (Now + TimeSerial(0, 0, 2)) [ô]Wait for Acrobat to load

SendKeys [Ô]^a[Ô] [ô]Select All
SendKeys [Ô]^c[Ô] [ô]Copy
SendKeys [Ô]%{F4}[Ô] [ô]Close shell application

wkSheet.Range([Ô]B5[Ô]).Select
SendKeys [Ô]^v[Ô] [ô]Paste

End Sub
Faça seu login para responder