• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Error in importing pdf files to excel using IE.

vijehspaul

Member
Hello,
I am trying to import some PDF files to excel using IE (open it in IE and copy-paste to excel ). My code is working for some pdf files. but for some it returns following error : The remote server machine does not exist or is unavailable
Searched many forums to resolve this, but all leads to much complicated solutions which is beyond my coding skills (still am a newbie )...
Please help.

My code:

Code:
Sub ImportPdf()
Dim FileName As String
Dim b2 As Workbook
Dim ie As Object
Dim np As Object
FileName="C:\somepdf.pdf"
Set b2 = ThisWorkbook
Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = True

ie.navigate (FileName)

Application.Wait Now + TimeSerial(0, 0, 8)

Do While ie.ReadyState <> 4                          ' 'ERROR comes here.
    DoEvents
Loop
AppActivate ie                  

SendKeys "^(a)", True
Application.Wait Now + TimeSerial(0, 0, 2)
SendKeys "^(c)", True
Application.Wait Now + TimeSerial(0, 0, 2)
b2.Activate 
Application.ScreenUpdating = False
With Sheets(2).Activate
    Range("A1").Select
    ActiveSheet.Paste
End With
Sheets(1).Activate
Application.ScreenUpdating = True

ie.Quit

End Sub

The pdf files have tables, images and vary in sizes. Working file is small in size.
Please help..
 
Last edited by a moderator:
if I remove the Do while loop, then error comes at AppActive ie line.
Tried even removing that line, but error comes at ie.quit line.

Please also suggest if there is any easy method to import pdf to excel. (text only )
 
Back
Top