user2774606
user2774606

Reputation: 11

Copy cell and paste to web form

I'm trying to create an order-tracking macro that does the following after I have selected a specific cell:

  1. Opens the order tracking webpage, e.g. FedEx shipment tracking
  2. Enters the value of a selected cell in my Excel spreadsheet into the appropriate search box on the webpage
  3. Clicks submit

I'm working in Excel 2010 off of a sample code I found on another forum. The code accomplishes everything EXCEPT pasting the value of a GIVEN cell. I can assign a numerical value or specific cell value to be entered, but I need a universal macro that I can use for any given cell.

I tried using some basic copy paste functions with the active cell. I managed to select and copy the active cell, but not to paste it into the search box.

Here is the code with problem sections identified.

Dim IE As Object

Sub submitFeedback3()

    Application.ScreenUpdating = False

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "TrackingWebsite"

    Application.StatusBar = "Submitting"
    ' Wait while IE loading...
    While IE.Busy
        DoEvents
        ActiveCell.Select
        Selection.Copy
    Wend
    ' **********************************************************************
    delay 1
        IE.Document.getElementById("receipt").Click
    delay 1
        IE.Document.getElementById("receipt").Paste
    delay 2
        IE.Document.getElementById("submit").Click
    '**********************************************************************

End Sub

Private Sub delay(seconds As Long)
    Dim endTime As Date
    endTime = DateAdd("s", seconds, Now())
    Do While Now() < endTime
        DoEvents
    Loop
End Sub

When I tried copy/paste code, I used the following underneath DoEvents:

ActiveCell.Select
Selection.Copy

Upvotes: 1

Views: 12306

Answers (1)

JaneGoodall
JaneGoodall

Reputation: 1506

IE.Document.getElementById("appReceiptNum").Click 
delay 1
IE.Document.getElementById("appReceiptNum").Paste

works for me, on a different site of course.

If it works for you too, make sure to upvote and click the check mark next to this answer!

Upvotes: 1

Related Questions