0

我有 VBA 代码,我可以在其中浏览网页,但 Sendkeys "^a"、"^c" 不起作用。尝试了多次,但没有运气。

请建议。

使用此代码:

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

我希望将数据粘贴到 excel 的活动表中

4

0 回答 0