- ©«¤l
- 40
- ¥DÃD
- 11
- ºëµØ
- 0
- ¿n¤À
- 100
- ÂI¦W
- 0
- §@·~¨t²Î
- Win8
- ³nÅ骩¥»
- Office2013
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- Taiwan
- µù¥U®É¶¡
- 2014-12-9
- ³Ì«áµn¿ý
- 2021-7-2
|
·Qn¦¹µ{¦¡ªºµ²ªG , ©Ò¥HCopy¨Ó¹B¥Î , ¦ý°õ¦æ®É³£¥X²{¦b Dim myDOC As HTMLDocument ³o¦æ , Åã¥Ü"¨Ï¥ÎªÌ¦Û©w«¬ºA©|¥¼©w¸q"ªº°ÝÃD¦Ó¤¤Â_ ,
½Ð°Ý³on¦p¦ó¥h¸Ñ¨M§r ?? TKS .
Sub ¦~«×ªÑ»ù_¤WÂd(StockNo)
theURL = "http://www.tpex.org.tw/web/stock/statistics/monthly/result_st42.php?timestamp=1405008334769"
Dim XMLHTTP
Set XMLHTTP = CreateObject("microsoft.xmlhttp")
Dim result As Variant
Dim TargetSheet As String
Dim myDOC As HTMLDocument
'¦s©ñHTMLªí®æ¸ê®Æ¤§¤u§@ªí
TargetSheet = "YearPrice"
With XMLHTTP
.Open "POST", theURL, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "Content-length", 45
.setRequestHeader "Connection", "close"
.send "ajax=true&input_stock_code=" & StockNo
End With
'«Ø¥ß HTML Document ª«¥ó
Set myDOC = New HTMLDocument
'±NXMLHTTPªº§ì¨ì¸ê®ÆˤJmyDOCª«¥ó
myDOC.body.innerHTML = XMLHTTP.responseText
Set XMLHTTP = Nothing
'¨ú±o©Ò¦³ªí®æ
Dim HTML_ALL_TABLE As Variant
Dim myTable As HTMLTable
Dim myRow As HTMLTableRow
Dim myCell As HTMLTableCell
'²M°£¤W¤@ÀɪºªÑ»ù
Sheets(TargetSheet).[A1:T200].ClearContents
Set myTable = myDOC.getElementsByTagName("TABLE").Item(2) '2014/01/03§ï
Debug.Print myTable.innerHTML
'§PÂ_¦³µLªÑ»ù¸ê®Æ¤§ª¬ªp
If myTable Is Nothing Then Exit Sub
'±NªÑ»ù¸ê®Æ§Û¨ìtemp¤u§@ªí
r = 2
For Each myRow In myTable.Rows
c = 0
For Each myCell In myRow.Cells
c = c + 1
If c = 6 Or c = 8 Then
Sheets(TargetSheet).Cells(r, c) = "'" & myCell.innerText
Else
Sheets(TargetSheet).Cells(r, c) = myCell.innerText
End If
DoEvents
Next
r = r + 1
Next
End Sub |
|