1,453
社区成员




Public Function GetInExcel(ChCodeText As String, ExcelPath As String, ExcelName As String, SheetName As String)
Dim PosStart As Integer
Dim PosStop As Integer
Dim IsOver As Boolean
Dim Time As String
Dim Show As String
Dim Row As Integer
PosStart = 1
PosStop = 1
IsOver = False
Row = 1
Dim XlsObj As Excel.Application 'Excel对象
Dim XlsBook As Excel.Workbook '工作簿
Dim XlsSheet As Excel.Worksheet '工作表
Set XlsObj = CreateObject("Excel.Application") '创建EXCEL对象
XlsObj.Visible = True '设置EXCEL对象可见(或不可见)
If Dir(ExcelPath & "\" & ExcelName) <> "" Then
XlsObj.Workbooks.Open (ExcelPath & "\" & ExcelName) '打开EXCEL工作簿
XlsObj.Sheets.Add After:=Sheets(Sheets.Count)
Set XlsSheet = XlsObj.Worksheets(Sheets.Count)
Else
'创建有一个工作表的工作簿
XlsObj.SheetsInNewWorkbook = 1
Set XlsBook = XlsObj.Workbooks.Add
Set XlsSheet = XlsObj.Worksheets(1)
End If
XlsSheet.name = SheetName
While IsOver = False
PosStart = PosStop
PosStart = InStr(PosStart, ChCodeText, "color:#") + 15
If PosStop - PosStart > 1000 Then
IsOver = True
Else
PosStop = PosStart + 5
Time = Mid(ChCodeText, PosStart, PosStop - PosStart) '写入excel时间
PosStart = PosStop + 7
If Mid(ChCodeText, PosStart, 1) = "<" Then
PosStart = InStr(PosStart, ChCodeText, ">") + 1
PosStop = InStr(PosStart, ChCodeText, "<")
Else
PosStop = InStr(PosStart, ChCodeText, "<")
End If
Show = Mid(ChCodeText, PosStart, PosStop - PosStart) '写入excel节目
End If
XlsSheet.cells(Row, 1) = Time
XlsSheet.cells(Row, 2) = Show
Row = Row + 1
Wend
XlsBook.SaveAs (ExcelPath & "\" & ExcelName)
Set XlsObj = Nothing
End Function