通过vba - 我需要转到page,然后选择选项“Hawb / direct awb no。”在Track下拉列表中,输入从excel复制到“Number”字段的单元格,然后单击“提交”按钮。
我该怎么办?我正在使用excel 10和IE 10.我尝试了各种各样的命令,但没有成功:(
ie.document.getElementById("ctl00_contentPlaceHolderRoot_cboTrackBy").Focus
ie.document.getElementById("ctl00_contentPlaceHolderRoot_cboTrackBy").Click
ie.document.getElementById("ctl00_contentPlaceHolderRoot_cboTrackBy").Value = "aw"
ie.document.getElementById("ctl00_contentPlaceHolderRoot_cboTrackBy").FireEvent ("onchange")
ie.document.getElementById("ctl00_contentPlaceHolderRoot_txtTrackBy").Value = b 'ctl00_contentPlaceHolderRoot_linkButtonSubmit
ie.document.getElementById("ctl00_contentPlaceHolderRoot_linkButtonSubmit")(0).Click
更新
我按照下面的ron的回答。我想复制一旦ron的代码完成它处理后得到的表。 我使用了追踪号码 - PEN91227308
我尝试了下面的命令。但它复制的数据不是表格格式。当我将它粘贴到excel中时,整个行显示在单个单元格上。我怎样才能将这些数据转换为网页上的表格格式?
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.PutInClipboard
clipboard.SetText Doc.getElementById("ctl00_contentPlaceHolderRoot_grdVwHistory").innerHTML
答案 0 :(得分:1)
您尝试与之互动的元素包含在IFrame中。源代码显示IFrame可以在
找到 <iframe name="Shipment Tracking" width="100%" height="450" id="content_iframe" src="http://apps.dbschenkerusa.com/apps/Tracking/" frameborder="0" scrolling="auto">
在该网址上,您可以使用以下代码1)选择正确的下拉框条目,2)在&#34;数字&#34;中输入数字值。文本框和3)单击&#34;提交&#34;按钮
Sub test1()
' open IE, navigate to the website of interest and loop until fully loaded
Set ie = CreateObject("InternetExplorer.Application")
' my_url = "http://www.dbschenkerusa.com/log-us-en/start/eschenkerusa/shipmenttracking.html"
my_url = "http://apps.dbschenkerusa.com/apps/Tracking/"
With ie
.Visible = True
.navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop
End With
' Select the appropriate item from the drop-down box
ie.Document.getElementById("ctl00_contentPlaceHolderRoot_cboTrackBy").Value = "aw"
' Enter a value in the "Number" text box
ie.Document.getElementById("ctl00_contentPlaceHolderRoot_txtTrackBy").Value = "1234"
' Click the submit button
ie.Document.getElementById("ctl00_contentPlaceHolderRoot_linkButtonSubmit").Click
End Sub