Pasar tabla de PDF a Excel
He buscado por el foro y por internet algún código VBA para pasar una tabla que tengo en PDF y pasarla a Excel. Después de mucho buscar solo encuentro lo de pasar de Excel a PDF. Aun que encontré un código que supuestamente lo hace pero me da error, tienes que activar las librerías de Acrobat para ejecutarlo pero aun así nada, ¿yo tengo el PDF 8 Profesional si selecciono la tabla y luego le doy a Copy As Table y voy a Excel y le doy a pegar me lo copia perfectamente pero no hay forma de automatizarlo?
Esto fue encontrado en un foro ingles:
Sub StartAdobe1()
Dim fName As Variant
Dim wbTransfer As Excel.Workbook
Dim wsNew As Excel.Worksheet
Dim dOpenCol As Double
Dim oPDFApp As AcroApp
Dim oAVDoc As AcroAVDoc
Dim oPDDoc As AcroPDDoc
'Define your spreadsheet
Set wbTransfer = Workbooks("transfer (Autosaved).xlsm")
Set wsNew = wbTransfer.Sheets("new")
'Find first open column
dOpenCol = ws.Cells(1, Columns.Count).End(xlToLeft).Column + 1
'Instantiate Acrobat Objects
Set oPDFApp = CreateObject("AcroExch.App")
Set oAVDoc = CreateObject("AcroExch.AVDoc")
Set oPDDoc = CreateObject("AcroExch.PDDoc")
For Each fName In Range("path")
'Open the PDF file. The AcroAVDoc.Open function returns a true/false
'to tell you if it worked
If oAVDoc.Open(fName.Text, "") = True Then
Set oPDDoc = oAVDoc.GetPDDoc
Else
Debug.Assert False
End If
'Copy all using Acrobat menu
oPDFApp.MenuItemExecute ("SelectAll")
oPDFApp.MenuItemExecute ("Copy")
'Paste into open column
wbTransfer.Activate
wsNew.Cells(1, dOpenCol).Select
ActiveSheet.Paste
'Select next open column
dOpenCol = dOpenCol + 1
oAVDoc.Close (1) '(1)=Do not save changes
oPDDoc.Close
Next
'Clean up
Set wbTransfer = Nothing
Set wsNew = Nothing
Set oPDFApp = Nothing
Set oAVDoc = Nothing
Set oPDDoc = Nothing
End SubPero no me funciona me sale error: Se ha producido el error '9' en tiempo de ejecución: Subíndice fuera del intervalo.
Al depurar me sale la linea:
Set wbTransfer = Workbooks("transfer (Autosaved).xlsm")
Respuesta de Abraham Valencia
1
