-
Notifications
You must be signed in to change notification settings - Fork 1
/
StopWatchProject.bas
162 lines (148 loc) · 19.3 KB
/
StopWatchProject.bas
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
Attribute VB_Name = "myProject"
Option Explicit
Private Type codeItem
extension As String
module_name As String
code_content() As String
End Type
Private Const TypeBinary = 1, vbext_pp_none = 0
Private Const ForReading = 1, ForWriting = 2, ForAppending = 8
Private Function getCodeDefinition(itemNo As Long) As codeItem
With getCodeDefinition
Select Case itemNo
Case 1
.extension = ".cls"
.module_name = "StopwatchResults"
ReDim .code_content(0 To 0)
.code_content(0) = "VkVSU0lPTiAxLjAgQ0xBU1MNCkJFR0lODQogIE11bHRpVXNlID0gLTEgICdUcnVlDQpFTkQNCkF0dHJpYnV0ZSBWQl9OYW1lID0gIlN0b3B3YXRjaFJlc3VsdHMiDQpBdHRyaWJ1dGUgVkJfR2xvYmFsTmFtZVNwYWNlID0gRmFsc2UNCkF0dHJpYnV0ZSBWQl9DcmVhdGFibGUgPSBGYWxzZQ0KQXR0cmlidXRlIFZCX1ByZWRlY2xhcmVkSWQgPSBGYWxzZQ0KQXR0cmlidXRlIFZCX0V4cG9zZWQgPSBGYWxzZQ0KT3B0aW9uIEV4cGxpY2l0DQoNClByaXZhdGUgVHlwZSBUU3RvcFdhdGNoUmVzdWx0cw0KICAgIFRpbWVEYXRhIEFzIE9iamVjdA0KICAgIExhYmVsRGF0YSB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3VycmVudExhYmVsLk5vZGVOYW1lICYgIl8NCiAgICBuZXdOb2RlLkxhYmVsVHlwZSA9IHN0cF9MYXBUaW1lDQogICAgDQogICAgSWYgdGhpcy5DdXJyZW50TGFiZWwgSXMgTm90aGluZyBUaGVuDQogICAgICAgIEVyci5EZXNjcmlwdGlvbiA9ICJObyB0ZXN0IGlzIGN1cnJlbnRseSBydW5uaW5nIHRvIHdyaXRlIGxhcCBkYXRhIHRvIg0KICAgICAgICBFcnIuUmFp" & _
"c2UgNQ0KICAgIEVsc2UNCiAgICAgICAgU2V0IG5ld05vZGUucGFyZW50Tm9kZSA9IHRoaXMuQ3VycmVudExhYmVsDQogICAgICAgIHRoaXMuQ3VycmVudExhYmVsLkNoaWxkTm9kZXMuQWRkIG5ld05vZGUsIG5ld05vZGUuTm9kZU5hbWUNCiAgICBFbmQgSWYNCiAgICANCiAgICANCiAgICAnU2F2ZSB0aW1lIGRhdGEgdG8gZGljdGlvbmFyeSBhbmQgcmV0dXJuIHRvIGV4ZWN1dGlvbg0KICAgIERpbSBkaWN0S2V5IEFzIFN0cmluZw0KICAgIGRpY3RLZXkgPSB0aGlzLkN1cnJlbnRMYWJlbC5Mb2NhdGlvbiAmICJfIiAmIG5ld05vZGUuTm9kZU5hbWUNCiAgICB0aGlzLmRhdGEuQWRkIGRpY3RLZXksIGNsb2NrVGltZXMNCiAgICB0aGlzLmRhdGEoZGljdEtleSkuVGltZU91dCA9IE1pY3JvVGltZXINCkVuZCBTdWINCg0KUHJpdmF0ZSBTdWIgQ2xhc3NfSW5pdGlhbGl6ZSgpDQogICAgU2V0IHRoaXMuZGF0YSA9IENyZWF0ZU9iamVjdCgiU2NyaXB0aW5nLkRpY3Rpb25hcnkiKQ0KRW5kIFN1Yg0K"
Case Else
.extension = "missing"
End Select
End With
End Function
Public Sub Extract()
Dim code_module As codeItem
Dim savedPath As String, basePath As String
Dim i As Long
'check if vbproject accessible
If Not project_accessible Then
MsgBox "The VBA project cannot be accessed programmatically. Ensure programmatic access to Office VBA project is enabled and that the workbook is not protected."
Exit Sub
End If
'check if temp folder acessible
i = 0
basePath = Environ$("Temp") & "\"
Do While True
i = i + 1
code_module = getCodeDefinition(i)
If code_module.extension = "missing" Then
Exit Do
Else
savedPath = createFile(code_module, basePath)
importFile savedPath
Kill savedPath
End If
Loop
removemodule "myProject"
End Sub
Private Function project_accessible() As Boolean
On Error Resume Next
With ThisWorkbook.VBProject
project_accessible = .Protection = vbext_pp_none
project_accessible = project_accessible And Err.Number = 0
End With
End Function
Private Function createFile(definition As codeItem, filePath As Variant) As String
Dim codeIndex As Long
Dim newFileObj As Object
Set newFileObj = CreateObject("ADODB.Stream")
newFileObj.Type = TypeBinary
'Open the stream and write binary data
newFileObj.Open
'create file from x64 string
With definition
Dim bytes() As Byte
Dim fullPath As String
fullPath = filePath & .module_name & .extension
bytes = FromBase64(Join(.code_content))
newFileObj.Write bytes
newFileObj.SaveToFile fullPath, ForWriting
createFile = fullPath
End With
End Function
Private Sub importFile(filePath As String)
ThisWorkbook.VBProject.VBComponents.Import filePath
End Sub
Private Function removemodule(moduleName As String) As Boolean
On Error Resume Next
With ThisWorkbook.VBProject.VBComponents
.Remove .item(moduleName)
End With
removemodule = Not (Err.Number = 9)
End Function
Private Function FromBase64(Text As String) As Byte()
Dim Out() As Byte
Dim b64(0 To 255) As Byte, str() As Byte, i&, j&, v&, b0&, b1&, b2&, b3&
Out = ""
If Len(Text) Then Else Exit Function
str = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
For i = 2 To UBound(str) Step 2
b64(str(i)) = i \ 2
Next
ReDim Out(0 To ((Len(Text) + 3) \ 4) * 3 - 1)
str = Text & String$(2, 0)
For i = 0 To UBound(str) - 7 Step 2
b0 = b64(str(i))
If b0 Then
b1 = b64(str(i + 2))
b2 = b64(str(i + 4))
b3 = b64(str(i + 6))
v = b0 * 262144 + b1 * 4096& + b2 * 64& + b3 - 266305
Out(j) = v \ 65536
Out(j + 1) = (v \ 256&) Mod 256
Out(j + 2) = v Mod 256
j = j + 3
i = i + 6
End If
Next
If b2 = 0 Then
Out(j - 3) = (v + 65) \ 65536
j = j - 2
ElseIf b3 = 0 Then
Out(j - 3) = (v + 1) \ 65536
Out(j - 2) = ((v + 1) \ 256&) Mod 256
j = j - 1
End If
ReDim Preserve Out(j - 1)
FromBase64 = Out
End Function