-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmSVCCommon.bas
240 lines (176 loc) · 5.66 KB
/
mSVCCommon.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
Attribute VB_Name = "mSVCCommon"
Option Explicit
Option Compare Text
Dim vCurrQueryTime
Global Const isDebug = True
Public vIsFirstRetrive As Boolean
Public vItWasOtlPage As Boolean
Public vActiveCell
Public vLastSheetName As String
Sub p_CheckConnection()
If ActiveSheet Is Nothing Then
MsgBox "active sheet is not determinated ", vbExclamation
End
End If
If Not HypConnected(Empty) Then
MsgBox "Please make connection with using SmartView panel ", vbExclamation
End If
End Sub
Function f_execSVMenu(strSVMenu As String) As Long
On Error Resume Next
Call p_CheckConnection
Call p_setExcelCalcOff
Application.EnableCancelKey = xlErrorHandler
f_execSVMenu = HypExecuteMenu(Empty, strSVMenu)
Application.EnableCancelKey = xlInterrupt
Call p_setExcelCalcOn
End Function
Sub p_execSVMenu(strSVMenu As String)
On Error Resume Next
X = f_execSVMenu(strSVMenu)
If X <> 0 Then
Call p_ErrorHandler(X, strSVMenu)
End
End If
End Sub
Sub p_WriteStatusBarTime()
'vCurrQueryTime = (Now - vCurrQueryTime)
Application.StatusBar = " Exec Time: " & DateDiff("s", vCurrQueryTime, Now) & " sec "
'Application.OnTime Now + TimeSerial(0, 0, 90), "p_ClearStatusBar"
End Sub
Sub p_ClearStatusBar()
On Error Resume Next
Application.StatusBar = False
End Sub
Sub p_setExcelCalcOff_()
On Error Resume Next
If ActiveSheet Is Nothing Then
MsgBox "active sheet is not determinated "
End
End If
vCurrQueryTime = Now
Application.EnableCancelKey = xlErrorHandler
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.UsedRange.EntireRow.Hidden = False
Set vActiveCell = Range(ActiveCell.Address)
If Err.Number <> 0 Then
Err.Clear
End If
End Sub
Sub p_setExcelCalcOn_()
On Error Resume Next
Call p_WriteStatusBarTime
On Error Resume Next
Application.EnableCancelKey = xlInterrupt
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.UsedRange.EntireRow.Hidden = False
If Err.Number <> 0 Then
Err.Clear
End If
End Sub
Sub p_setExcelCalcOff()
If ActiveSheet Is Nothing Then
MsgBox "active sheet is not determinated "
End
End If
On Error Resume Next
vCurrQueryTime = Now
Application.EnableCancelKey = xlErrorHandler
Application.ScreenUpdating = False
' Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.UsedRange.EntireRow.Hidden = False
Set vActiveCell = Range(ActiveCell.Address)
If Err.Number <> 0 Then
Err.Clear
End If
End Sub
Sub p_setExcelCalcOn_INT()
On Error Resume Next
Application.EnableCancelKey = xlInterrupt
Application.ScreenUpdating = True
' Application.DisplayStatusBar = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.UsedRange.EntireRow.Hidden = False
ActiveSheet.UsedRange.Select
Selection.NumberFormat = "#,##0.00"
Application.CutCopyMode = False
vActiveCell.Select
If Err.Number <> 0 Then
Err.Clear
End If
End Sub
Sub p_setExcelCalcOn()
On Error Resume Next
Call p_WriteStatusBarTime
X = HypShowPov(isHypShowPov)
X = 0
Call p_setExcelCalcOn_INT
ActiveSheet.Outline.ShowLevels RowLevels:=1
End Sub
Function CheckIfSheetExists(SheetName As String) As Boolean
CheckIfSheetExists = False
Dim ws As Worksheet
For Each ws In Worksheets
If SheetName = ws.Name Then
CheckIfSheetExists = True
Exit Function
End If
Next ws
End Function
Sub p_ErrorHandler(vErrNum As Long, p As String)
Dim vErrStr
Dim vButton
Dim vErrorHandler
vErrStr = ""
If (Err.Number <> 0) Then
vErrStr = vErrStr & "Error # " & Str(Err.Number) & " was generated by " _
& Err.source & vbCrLf & "Error Line: " & Erl & vbCrLf & Err.Description
vButton = vbCritical
End If
If vErrNum = -4 And (Err.Number = 0) Then
MsgBox "The connection was lost. Please make new one " & p, vbExclamation
X = HypDisconnect(Empty, True)
End
End If
If vErrNum = 4 And (Err.Number = 0) Then
MsgBox " Unknown SmartView Error . Please Restart Excel ", vbExclamation
X = HypDisconnect(Empty, True)
End
End If
If X = -15 And (Err.Number = 0) Then
MsgBox " You need to change language of SmartView from local to English." & Chr(13) & " Go To Additionals->Options ", vbExclamation
End
End If
If isDebug Then
If vErrNum <> 0 And (vErrNum <> 4) And (vErrNum <> 1020021) Then
vErrStr = vErrStr & vbCrLf & getErrorText(vErrNum)
End If
vErrStr = vErrStr & vbCrLf & p
End If
vButton = vbCritical
vErrorHandler = "Error"
If (Err.Number = 0) Then
vButton = vbExclamation
vErrorHandler = "Warning"
End If
If vErrStr <> "" Then
MsgBox vErrStr, vButton, vErrorHandler
End If
X = 0
If Err.Number <> 0 Then
Err.Clear
End If
p_setExcelCalcOn_
End
End Sub