|
楼主 |
发表于 2013-3-23 17:14
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
【原帖】 [求助] 有朋友要的提取大智慧软件历史数据的代码
http://club.excelhome.net/thread-988226-1-1.html- Sub GetStockAllData()
- On Error Resume Next
- StockCode = "600000"
- If Len(StockCode) <> 6 Then Exit Sub
- If Left(StockCode, 2) = 60 Then
- openfile = "E:\DZH5\DATA\SHase\Day" & StockCode & ".day"
- Else
- openfile = "E:\DZH5\DATA\SZnse\Day" & StockCode & ".day"
- End If
- Sheets(1).Select
- Range("A:P").ClearContents
- Dim File2 As Integer
- Dim b As MyType
- Dim DayNum
- file1 = FreeFile
- Open openfile For Binary Access Read As #file1
- DayNum = LOF(file1) / 40
- ReDim arr(DayNum, 7)
- 'i = 1
- Do While Not EOF(file1)
- Get #file1, , b
- arr(i, 0) = b.a1
- arr(i, 1) = b.a2 / 1000
- arr(i, 2) = b.a3 / 1000
- arr(i, 3) = b.a4 / 1000
- arr(i, 4) = b.a5 / 1000
- arr(i, 5) = b.a6 / 1000
- arr(i, 6) = b.a7
- i = i + 1
- Loop
- Sheet1.Range("a2").Resize(UBound(arr), 7) = arr
- [a1:g1] = Split("日期,开盘价,最高价,最低价,收盘价,成交金额,成交量", ",")
- Columns("b:f").NumberFormat = "0.00"
- Close #file1
- End Sub
复制代码 插入模块,加入如下代码
Type MyType
a1 As Long '标示码
a2 As Long '日期
a3 As Long '开盘价
a4 As Long '最高价
a5 As Long '最低价
a6 As Long '收盘价
a7 As Long '成交金额
a8 As Long '成交量
a9 As Long
a10 As Long
End Type
|
|