本帖最后由 HYY514 于 2011-3-19 12:32 编辑
http://www.szse.cn/main/disclosure/news/scgkxx/index.shtml 导出:
Sub fff()
Dim st As Date
Dim sp As Date
Dim i As Date
Dim shtm As String
Dim sDate As String
Dim sMsg As String
st = "2011-02-11"
sp = "2011-03-11"
With CreateObject("MICROSOFT.XMLHTTP")
For i = st To sp
sDate = Format(i, "yymmdd")
.Open "get", "http://www.szse.cn/szseWeb/common/szse/files/text/jy/jy" & sDate & ".txt", False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send ""
shtm = StrConv(.responseBody, vbUnicode)
If InStr(shtm, "深圳证券市场") Then
toTXT shtm, i
'toSheet shtm, i
Else
sMsg = sMsg & i & vbCrLf
End If
Next
End With
If Len(sMsg) Then MsgBox sMsg & "无记录!"
Shell "explorer.exe " & ThisWorkbook.Path, vbNormalNoFocus
End Sub
Sub toTXT(s As String, ByVal sN As String)
Open ThisWorkbook.Path & "\" & sN & ".txt" For Output As #1
Print #1, s
Close #1
End Sub
Sub toSheet(s As String, ByVal sN As String)
Dim cl As New DataObject
With cl
.Clear
.SetText s
.PutInClipboard
End With
Sheets.Add(, Sheets(Sheets.Count)).name = sN
ActiveSheet.Paste
End Sub