- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
19#
發表於 2014-12-16 10:20
| 只看該作者
回復 15# HSIEN6001
若不用寫入Excel,而直接 .Click 下載CSV檔(BIG5) 檔案
對IE的涉獵尚淺找不出下載CSV檔的參數,有請高手指點
載入其他頁次
Dim IEx As Object '工作表模組- Private Sub 日報表載入()
- Dim e As Object, A As Object, k As Integer, i As Integer, S As String
- If IE Is Nothing Then
- 圖形更新
- MsgBox "驗證圖已更新"
- Exit Sub
- End If
- With IE
- .Document.all.tags("INPUT")("stk_code").Value = Range(證券代號)
- .Document.all.tags("INPUT")("auth_num").Value = Trim(Range(驗證碼))
- Set A = .Document.all.tags("BUTTON")
- For Each e In A
- If Trim(e.Innertext) = "查詢" And e.ID = "" Then
- e.Click
- Exit For
- End If
- Next
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- UsedRange.Offset(6).Clear
- Range("a" & k + 1) = S
- If .Document.body.Innertext Like "***該股票該日無交易資訊***" Then S = "***該股票該日無交易資訊***"
- If .Document.body.Innertext Like "***驗證碼錯誤,請重新查詢。***" Then S = "***驗證碼錯誤,請重新查詢。*** "
- If S <> "" Then
- Range("a" & k + 1) = S
- MsgBox S
- GoTo NN
- End If
- Set IEx = CreateObject("InternetExplorer.Application")
- IEx.Navigate "about:Tabs"
- Set A = .Document.all.tags("A")
- 單頁載入 .Document.all.tags("table")(0).outerHTML
- [A6].Select
- '********程式碼寫在工作表模組: Me 指這工作表模組
- Me.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
- '****************************************
- If A.Length = 459 Then
- For i = 2 To 3
- 單頁載入 .Document.all.tags("table")(i).outerHTML
- With Range("A" & Rows.Count).End(xlUp).Offset(1)
- .Select
- Me.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
- End With
- Next
- Else
- For k = 0 To A.Length - 1
- If Val(A(k).Innertext) >= 1 Then
- Debug.Print A(k).Innertext
- A(k).Click
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Set A = .Document.all.tags("A")
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- For i = 2 To 3
- 單頁載入 .Document.all.tags("table")(i).outerHTML
- With Range("A" & Rows.Count).End(xlUp).Offset(1)
- .Select
- Me.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
- End With
- Next
- End If
- Next
- End If
- IEx.Quit
- Set IEx = Nothing
- 整理
- NN:
- .Quit
- End With
- Set IE = Nothing
- 圖形更新
- End Sub
- Private Sub 單頁載入(S)
- With IEx
- .Document.body.innerHTML = S
- .ExecWB 17, 2 ' Select All
- .ExecWB 12, 2 ' Copy selection
- End With
- End Sub
- Private Sub 整理()
- On Error Resume Next
- Application.EnableEvents = False
- With UsedRange.Offset(10)
- .Replace "序號", "=ex", xlWhole
- .SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Delete
- End With
- UsedRange(1).Select
- Application.EnableEvents = True
- End Sub
複製代碼 |
|