This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
VBcode
67 lines (58 loc) · 2.49 KB
/
VBcode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'Loads data from text file into as a string array
Dim lines() As String = File.ReadAllLines("C:\Users\stoloff.daniel\Desktop\Yammer.txt")
'Declares m as the place in the array
Dim m As Integer = 0
'Initializes Excel
Dim XlApp As Excel.Application
Dim XlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
XlApp = New Excel.Application
XlWorkbook = XlApp.Workbooks.Open("C:\Users\stoloff.daniel\Desktop\Yammer Spreadsheet.xlsx")
xlWorksheet = XlWorkbook.Worksheets(1)
'Declares Row and Column as the location in the Excel spreadsheet
Dim Row As Integer = 1
Dim Column As Integer = 1
Do
Label1.Text = m & " out of " & lines.Length
'Exits Loop when reached the end of the text file
If m = lines.Length Then
Exit Do
End If
If InStr(lines(m), "FollowFollow") Then
'Finding a FollowFollw starts a new thread. Moves excel to the next row and to the first column.
Row += 1
Column = 1
'User Name
xlWorksheet.Cells(Row, Column) = Mid(lines(m), 1, InStr(lines(m), "FollowFollow") - 1)
Column += 1
'Time Stamp
xlWorksheet.Cells(Row, Column) = lines(m + 2)
Column += 1
'Threads without comments have the message three lines after the start, threads with comments four lines after
'Uses the "Translated form English" or blank lines as markers for whether it has comments
If InStr(lines(m + 4), "English") Or Len(Trim(lines(m + 4))) = 0 Then
xlWorksheet.Cells(Row, Column) = lines(m + 3)
Else
xlWorksheet.Cells(Row, Column) = lines(m + 4)
End If
Column += 1
End If
'All replys follow the same pattern. Does not change row for the replys
If InStr(lines(m), "in reply to") And InStr(lines(m), "-") = False Then
'User Name
xlWorksheet.Cells(Row, Column) = Mid(lines(m), 1, InStr(lines(m), "in reply to") - 1)
Column += 1
'Time Stamp
xlWorksheet.Cells(Row, Column) = lines(m + 2)
Column += 1
'Message
xlWorksheet.Cells(Row, Column) = lines(m + 3)
Column += 1
End If
'Moves forward in the array
m += 1
Loop
'Saves and closes the excel file.
XlWorkbook.Save()
XlWorkbook.Close()
XlApp.Quit()