2013-05-03 92 views
0

下面的代碼是我的問題。它意味着將來自網站的資金信息複製到電子表格中。當這些資金在非pdf網站上運行時,它運行良好,但它不適用於pdf網站。這是Select-All(ie2.ExecWB 17,0)失敗,我無法破解它。如果我在pdf網站上使用鍵盤ctrl-A,它會選擇所有和sendkeys版本的一半作品,但我需要的是解決方案來獲取此「ie2.ExecWB 17,0」來完成它應該做的事情。 任何幫助非常感謝。 歡呼Excel VBA到Internet Explorer - 選擇所有不能在PDF上工作

子ListFunds()

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 

末次

+0

你知道pdf是從應用程序還是IE瀏覽器打開嗎? (這可以在瀏覽器中的客戶端級別設置)這可能是導致問題的原因。 – 2013-05-03 18:03:13

+0

你可以得到像[Fiddler](http://fiddler2.com/get-fiddler)這樣的東西來檢查正在傳輸的http頭文件。這可能會揭示這個問題。我知道我在嘗試從HTTPS站點訪問一些數據時廣泛使用它。 – Marshall 2013-05-03 20:43:05

回答

1

檢查了這一點,這可能會幫助您:

http://www.xtremevbtalk.com/showthread.php?t=299104

我不是瘋了有關的SendKeys可言,但我想不出通過瀏覽器從PDF獲取數據的另一種方式。

+0

謝謝,我似乎已經在那裏使用該鏈接上的信息。我的代碼仍然有點脾氣,但它的工作。 Sendkeys似乎是目前唯一的解決方案。在ExecWB之前,我期待着一些命令來使它們工作。謝謝。 – 2013-05-04 15:29:09

+0

@PaulSymms很高興你得到它的工作!您能否將我的答案標記爲已接受的答案? – 2013-05-04 15:52:07

相關問題