下面的代码是我的问题。它旨在将基金信息从网站复制到电子表格中。当资金在非 pdf 网站上时效果很好,但不适用于 pdf 网站。是 Select-All (ie2.ExecWB 17, 0) 失败了,我无法破解它。如果我在 pdf 网站上执行键盘 ctrl-A,它会选择所有并且 sendkeys 版本的一半可以工作,但我需要一个解决方案来让这个“ie2.ExecWB 17, 0”完成它应该做的事情。非常感谢任何帮助。干杯
子列表基金()
Dim DataObj As New MSForms.DataObject
Dim S As String
Dim ie1, ie2
Set ie1 = CreateObject("internetexplorer.application")
Set ie2 = CreateObject("internetexplorer.application")
HWNDSrc = ie2.HWND
ie1.Visible = True
ie2.Visible = True
ie1.navigate "http://www.legalandgeneral.com/workplacebenefits/employees/help-support/fund-zone/fund-factsheets/wpp-tbop-pptip.html"
Do Until ie1.readystate = 4
DoEvents
Loop
Dim LinkFound As Boolean
Dim linkCollection
Set linkCollection = ie1.document.all.tags("A")
For Each link In linkCollection
If InStr(1, link.outerhtml, "fundslibrary") <> 0 Then
ie2.navigate link
Do Until ie2.readystate = 4
DoEvents
Loop
ie2.ExecWB 17, 0 '// SelectAll
ie2.ExecWB 12, 2 '// Copy selection
DataObj.GetFromClipboard
S = DataObj.GetText
Selection.Value = S
Selection.Offset(1, 0).Select
End If
Next link
ie1.Quit
ie2.Quit
结束子