- 帖子
- 2035
- 主題
- 24
- 精華
- 0
- 積分
- 2031
- 點名
- 0
- 作業系統
- Win7
- 軟體版本
- Office2010
- 閱讀權限
- 100
- 性別
- 男
- 註冊時間
- 2012-3-22
- 最後登錄
- 2024-2-1
|
回復 17# GBKEE
測試用 (已套用您建議之函數)- Sub Test()
- Dim xTable As Object, k As Integer, C As Integer, R As Integer ' , sn As Integer
- Dim url As String, cts As Integer, E As Variant, xDate As String ' , rc As Integer
- Dim oXmlhttp As Object, oHtmldoc As Object, select2 As String ' , tm
- Dim TVal() As Variant
-
- If Select_Name = -1 Then Exit Sub
- TVal = Array("MS", "ALL", "0049", "0099P", "019919T", "0999", "0999P", "01", "02", "03", _
- "04", "05", "06", "07", "21", "22", "08", "09", "10", _
- "11", "12", "13", "24", "25", "26", "27", "28", "29", _
- "30", "31", "14", "15", "16", "17", "18", "23", "9299", "19", "20", "CB")
-
- xDate = Format(Sheets("總表").[B1], "EE/MM/DD")
- url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=" & TVal(Select_Name)
- 'url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=" & Select_Name
- 'url = "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php?qdate=" & xDate & "&selectType=水泥工業"
- Set oXmlhttp = CreateObject("msxml2.xmlhttp")
- Set oHtmldoc = CreateObject("htmlfile")
- With oXmlhttp
- .Open "Get", url, False
- .Send
-
- Do While .Status <> 200 Or .readyState <> 4: DoEvents: Loop
-
- oHtmldoc.write .responseText
- 'MsgBox .responseText
- End With
-
- Set xTable = oHtmldoc.ALL.tags("TABLE")
- ' Stop
- ' 看看區域變數視窗 xTable 的內容
- Set xTable = oHtmldoc.ALL.tags("TABLE")(0)
- ' Stop
- ' 再次看看區域變數視窗 xTable 的內容
- MsgBox xTable.INNERTEXT
- End Sub
- Private Function Select_Name() As Integer
- With Sheets("總表").ComboBox1
- If .ListIndex = -1 Then MsgBox ("您尚未選擇「產業類別」,請於" & vbCrLf & "確認後再次點選『開啟網頁』," & vbCrLf & "謝謝您!")
- Select_Name = .ListIndex ' Select_Name = -1,0,1,2,3,4,5,6,7,8,9,.....39
- End With
- End Function
複製代碼
|
|