-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathEXCEL_CONTROL_LIBR.bas
executable file
·199 lines (160 loc) · 6.38 KB
/
EXCEL_CONTROL_LIBR.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
Attribute VB_Name = "EXCEL_CONTROL_LIBR"
Option Explicit 'Requires that all variables to be declared explicitly.
Option Base 1 'The "Option Base" statement allows to specify 0 or 1 as the
'default first index of arrays.
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_SHOW_ADDIN_FUNC
'DESCRIPTION : Show Addin
'LIBRARY : EXCEL
'GROUP : ADD_IN
'ID : 001
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_SHOW_ADDIN_FUNC(Optional ByRef SRC_WBOOK As Excel.Workbook)
On Error GoTo ERROR_LABEL
EXCEL_SHOW_ADDIN_FUNC = False
If SRC_WBOOK Is Nothing Then: Set SRC_WBOOK = ActiveWorkbook
SRC_WBOOK.IsAddin = False
EXCEL_SHOW_ADDIN_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_SHOW_ADDIN_FUNC = False
End Function
'************************************************************************************
'************************************************************************************
'FUNCTION : ADDIN_HIDE
'DESCRIPTION : Hide Addin
'LIBRARY : EXCEL
'GROUP : ADD_IN
'ID : 002
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_HIDE_ADDIN_FUNC(Optional ByRef SRC_WBOOK As Excel.Workbook)
On Error GoTo ERROR_LABEL
EXCEL_HIDE_ADDIN_FUNC = False
If SRC_WBOOK Is Nothing Then: Set SRC_WBOOK = ActiveWorkbook
SRC_WBOOK.IsAddin = True
EXCEL_HIDE_ADDIN_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_HIDE_ADDIN_FUNC = False
End Function
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_CHANGE_REFERENCE_STYLE_FUNC
'DESCRIPTION : Change Reference Style
'LIBRARY : EXCEL
'GROUP : CONTROL
'ID : 001
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_CHANGE_REFERENCE_STYLE_FUNC(Optional ByVal VERSION As Long = 0)
On Error GoTo ERROR_LABEL
EXCEL_CHANGE_REFERENCE_STYLE_FUNC = False
Select Case VERSION
Case 0
Excel.Application.ReferenceStyle = xlR1C1
Case Else
Excel.Application.ReferenceStyle = xlA1
End Select
EXCEL_CHANGE_REFERENCE_STYLE_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_CHANGE_REFERENCE_STYLE_FUNC = False
End Function
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_DISPLAY_ALERTS_FUNC
'DESCRIPTION : Turn on/off Display Alerts
'LIBRARY : EXCEL
'GROUP : CONTROL
'ID : 002
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_DISPLAY_ALERTS_FUNC(Optional ByVal VERSION As Boolean = True)
On Error GoTo ERROR_LABEL
EXCEL_DISPLAY_ALERTS_FUNC = False
Select Case VERSION
Case Is = True
Excel.Application.DisplayAlerts = True
Case Is = False
Excel.Application.DisplayAlerts = False
End Select
EXCEL_DISPLAY_ALERTS_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_DISPLAY_ALERTS_FUNC = False
End Function
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_TURN_OFF_EVENTS_FUNC
'DESCRIPTION : Turn off events in Excel
'LIBRARY : EXCEL
'GROUP : CONTROL
'ID : 006
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_TURN_OFF_EVENTS_FUNC()
On Error GoTo ERROR_LABEL
EXCEL_TURN_OFF_EVENTS_FUNC = False
With Excel.Application
.EnableEvents = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
.Cursor = xlWait
.StatusBar = False
End With
EXCEL_TURN_OFF_EVENTS_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_TURN_OFF_EVENTS_FUNC = False
End Function
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_TURN_ON_EVENTS_FUNC
'DESCRIPTION : Turn on events in Excel
'LIBRARY : EXCEL
'GROUP : CONTROL
'ID : 007
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Function EXCEL_TURN_ON_EVENTS_FUNC()
On Error GoTo ERROR_LABEL
EXCEL_TURN_ON_EVENTS_FUNC = False
With Excel.Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.EnableEvents = True
.Cursor = xlDefault
.StatusBar = False
End With
EXCEL_TURN_ON_EVENTS_FUNC = True
Exit Function
ERROR_LABEL:
EXCEL_TURN_ON_EVENTS_FUNC = False
End Function
'************************************************************************************
'************************************************************************************
'FUNCTION : EXCEL_CALCULATE_FULL_REBUILD_FUNC
'DESCRIPTION : Calculate Full Rebuild Sheet
'LIBRARY : EXCEL
'GROUP : CONTROL
'ID : 009
'AUTHOR : RAFAEL NICOLAS FERMIN COTA
'************************************************************************************
'************************************************************************************
Sub EXCEL_CALCULATE_FULL_REBUILD_FUNC()
On Error Resume Next
If Val(Excel.Application.VERSION) < 10 Then
Excel.Application.CalculateFull
Else
Excel.Application.CalculateFullRebuild
End If
End Sub