[英]microsoft excel vba copying data from webpage
through vba - I need to go to the page , then select option "Hawb/direct awb no." 通过vba-我需要转到页面 ,然后选择选项“ Hawb / direct awb no”。 in Track by drop down, enter a cell copied from excel into "Number" field and then click "submit" button.
在“跟踪方式”下拉列表中,输入从excel复制到“数字”字段中的单元格,然后单击“提交”按钮。
how can i do it? 我该怎么做? I am using excel 10 and IE 10. I tried variety of commands like below but no success :(
我正在使用excel 10和IE10。我尝试了如下所示的各种命令,但未成功:(
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
update: 更新:
I followed ron's answer below. 我遵循了罗恩的回答。 I want to copy tables that i get once ron's code finishes it's processing.
我想复制ron的代码完成处理后得到的表。 I used tracking number - PEN91227308
我使用了跟踪号-PEN91227308
I tried below commands. 我尝试了以下命令。 But the data that it copies is not in a table format.
但是它复制的数据不是表格格式。 When i paste it in excel entire row appears on a single cell.
当我将其粘贴到Excel中时,整行显示在单个单元格上。 How could i convert that data into table format as on the webpage?
我如何像在网页上那样将数据转换为表格格式?
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.PutInClipboard
clipboard.SetText Doc.getElementById("ctl00_contentPlaceHolderRoot_grdVwHistory").innerHTML
The elements you are trying to interact with are contained within an IFrame. 您尝试与之交互的元素包含在IFrame中。 The source code shows that the IFrame can be found at
源代码显示可以在以下位置找到IFrame
<iframe name="Shipment Tracking" width="100%" height="450" id="content_iframe" src="http://apps.dbschenkerusa.com/apps/Tracking/" frameborder="0" scrolling="auto">
At that url, you can use the following code to 1) select the correct drop-down box entry, 2) enter your numeric value in the "Number" text box and 3) click the "Submit" button 在该网址上,您可以使用以下代码进行以下操作:1)选择正确的下拉框条目,2)在“数字”文本框中输入数字值,然后3)单击“提交”按钮
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.