- 帖子
- 523
- 主題
- 56
- 精華
- 0
- 積分
- 601
- 點名
- 85
- 作業系統
- win 10
- 軟體版本
- []
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2013-3-19
- 最後登錄
- 2025-4-12
           
|
4#
發表於 2020-3-8 14:28
| 只看該作者
本帖最後由 Scott090 於 2020-3-8 14:34 編輯
回復 3# PKKO
再測試如下:
Sub test1()
Dim QT As QueryTable
Dim WebAddress As String
' WebAddress = "http://www.cnyes.com/twstock/ps_historyprice/2327.htm"
WebAddress = "https://www.cnyes.com/twstock/ps_historyprice.aspx?code=2327"
With ThisWorkbook.Worksheets("DL")
.Cells.Clear
Set QT = .QueryTables.Add("URL;" & WebAddress, .Range("$A$1"))
End With
With QT
'.PostText = "ctl00$ContentPlaceHolder1$startText=" & " 2019/01/01" & "&ctl00$ContentPlaceHolder1$endText=" & " 2020/03/06"
'日期與等號間不要有空格
'======================
.PostText = "ctl00$ContentPlaceHolder1$startText=" & "2019/01/01" & "&ctl00$ContentPlaceHolder1$endText=" & "2020/03/06"
.WebTables = "1"
.Refresh False
.Delete
End With
End Sub |
|