金害~!我只能捉到它的 個股基本資料
為什麼捉不到我要的資料呢?
Private Sub CommandButton1_Click()
Dim webURL As String
webURL = "URL;http://jsjustweb.jihsun.com.tw/z/zc/zcx/zcx_6257.asp.htm"
With ActiveSheet.QueryTables.Add(Connection:=webURL, Destination:=Range("A1"))
' xlOverwriteCells 表示覆蓋欄位
.RefreshStyle = xlOverwriteCells
.WebTables = "1"
.Refresh BackgroundQuery:=False
End With
End Sub作者: chen_cook 時間: 2012-5-1 06:56
I copied you codes but it doesn't work.
However, I'm new to this forum & do not have enough point to download your ademo.zip.
Could you please post your codes in ademo.zip for my reference ?
Sub Test()
Dim x, ur As String
x = Worksheets("sheet1").Range("a1")
Const url As String = "http://jsjustweb.jihsun.com.tw/z/zc/zcl/zcl_AAAA.asp.htm"
MsgBox url
ur = "http://jsjustweb.jihsun.com.tw/z/zc/zcl/zcl_" & x & ".asp.htm"
MsgBox ur
Cells.Clear
Set ie = CreateObject("internetexplorer.application") '使用此方式可以免除 "設定引用項目"
With ie
.Visible = False 'True為開啟ie, False為不開啟ie
.Navigate url
Do While .ReadyState <> 4 '等待網頁開啟
DoEvents
Loop
.ExecWB 17, 2 'Select All
.ExecWB 12, 2 'Copy selection
Sheets("Sheet1").Cells.Select
Range("AA1").Activate
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
End With
Columns("A:B").Delete
ie.Quit
MsgBox "資料複製結束"
End Sub
With ActiveSheet.QueryTables.Add(Connection:="URL;http://mops.twse.com.tw/mops/web/t56sb21_q3?encodeURIComponent=1&run=Y&step=1&TYPEK=sii&year=105&smonth=01&emonth=02&sstep=1&firstin=true", Destination:=Range("A1"))
Cells.Clear
surl = "http://isin.twse.com.tw/isin/C_public.jsp?strMode=2"
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="URL;" & surl, Destination:=Range("$A$1"))
.Refresh BackgroundQuery:=False
End With