楼主 xmyjk |
- Option Explicit
- Dim Interval As Date
- Sub autoref()
- Dim tmp() As String, i As Integer, arr() As String, xmlhttp As Object
-
- [h1:m1] = Split("货币,最新价,最高价,最低价,升跌,更新时间", ",")
- [m2] = Format(Date, "yyyy年mm月dd日") & Format(Time, "Long Time")
-
- On Error Resume Next
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- With xmlhttp
- .Open "get", "http://www.hx9999.com/api/gold.php?" & Rnd, False
- .send
- tmp() = Filter(Split(Replace(Replace(Replace(.responsetext, "align=""center"" style=""color:Red"">", ""), "align=""center"" style=""color:Green"">", ""), "align=""center"" style=""color:Black"">", ""), "align=""center"""), "</td>")
- End With
- ReDim arr(UBound(tmp) \ 5, 4)
- For i = 0 To UBound(tmp)
- arr(i \ 5, i Mod 5) = Split(Split(tmp(i), "</td>")(0), ">")(1)
- Next
- [h1].Resize(UBound(arr, 1) + 1, UBound(arr, 2) + 1) = arr
-
- [h:m].Columns.AutoFit
- Erase tmp
- Erase arr
- Set xmlhttp = Nothing
-
- Range("A2:F2").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
- Range("H2:M2").Copy Destination:=Range("A2")
-
- Interval = Now + TimeSerial(0, 0, 10) '10秒钟刷新一次
- Application.OnTime Interval, "autoref"
- End Sub
- Sub autostop()
- Application.OnTime Interval, "autoref", , False
- End Sub
- Sub ref()
- Dim tmp() As String, i As Integer, arr() As String, xmlhttp As Object
-
- [h1:m1] = Split("货币,最新价,最高价,最低价,升跌,更新时间", ",")
- [m2] = Format(Date, "yyyy年mm月dd日") & Format(Time, "Long Time")
-
- On Error Resume Next
- Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
- With xmlhttp
- .Open "get", "http://www.hx9999.com/api/gold.php?" & Rnd, False
- .send
- tmp() = Filter(Split(Replace(Replace(Replace(.responsetext, "align=""center"" style=""color:Red"">", ""), "align=""center"" style=""color:Green"">", ""), "align=""center"" style=""color:Black"">", ""), "align=""center"""), "</td>")
- End With
- ReDim arr(UBound(tmp) \ 5, 4)
- For i = 0 To UBound(tmp)
- arr(i \ 5, i Mod 5) = Split(Split(tmp(i), "</td>")(0), ">")(1)
- Next
- [h1].Resize(UBound(arr, 1) + 1, UBound(arr, 2) + 1) = arr
-
- [h:m].Columns.AutoFit
- Erase tmp
- Erase arr
- Set xmlhttp = Nothing
-
- Range("A2:F2").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
- Range("H2:M2").Copy Destination:=Range("A2")
-
- MsgBox "手动刷新成功!"
- End Sub
现货黄金new.rar |