0

I have VBA Code where I am able to browse webpage but Sendkeys "^a", "^c" not working. Tried multiple times but no luck.

Please suggest.

Using this code:

Set DestinationWorksheet = ActiveSheet
Dim myURL As String

    Dim HTMLdoc As HTMLDocument
    Dim TDelements As IHTMLElementCollection
    Dim TDelement As HTMLTableCell
    Dim r As Long
    Dim date_now As String
    Set ie = CreateObject("InternetExplorer.Application")
    myURL = "https://www.annauniv.edu/pdf/pdf19.pdf"
    With ie
        .navigate myURL
        .Visible = True
 Do While ie.busy
        Application.Wait DateAdd("s", 1, Now)
    Loop
            Set HTMLdoc = .document
        End With

      SendKeys "^a"                                                                 ' Select all in PDF document
      SendKeys "^c"                                                                 ' Copy selected contents

      Application.Wait Now + TimeValue("00:00:02")                                  ' Wait a little to give clipboard time to copy (if huge contents)

      DoEvents

      SendKeys "^q"                                                                 ' Close PDF document

      Application.Wait Now + TimeValue("00:00:01")                                  ' Wait a little to give document time to close completely
      Application.Run "ActivateExcel", True                                         ' Re-activate Excel in case another application was activate when closing PDF Reader
      DoEvents

      Err.Clear
      DestinationWorksheet.Paste                                                    ' Paste PDF contents into worksheet

I expect the data to be pasted in activesheet of excel

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • Is not sufficient to just download document as is? https://stackoverflow.com/questions/43038325/how-to-download-a-pdf-file-from-browser-using-excel-vba – QHarr Jul 14 '19 at 12:01
  • Hi QHarr, I can download PDF file from web, but I want to get the PDF data into excel sheet.. – Mukunda Adhikari Jul 15 '19 at 06:10

0 Answers0