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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
|
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "MigrationAnalyser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'/*************************************************************************
' *
' * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
' *
' * Copyright 2008 by Sun Microsystems, Inc.
' *
' * OpenOffice.org - a multi-platform office productivity suite
' *
' * $RCSfile: MigrationAnalyser.cls,v $
' *
' * This file is part of OpenOffice.org.
' *
' * OpenOffice.org is free software: you can redistribute it and/or modify
' * it under the terms of the GNU Lesser General Public License version 3
' * only, as published by the Free Software Foundation.
' *
' * OpenOffice.org is distributed in the hope that it will be useful,
' * but WITHOUT ANY WARRANTY; without even the implied warranty of
' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' * GNU Lesser General Public License version 3 for more details
' * (a copy is included in the LICENSE file that accompanied this code).
' *
' * You should have received a copy of the GNU Lesser General Public License
' * version 3 along with OpenOffice.org. If not, see
' * <http://www.openoffice.org/license.html>
' * for a copy of the LGPLv3 License.
' *
' ************************************************************************/
Option Explicit
Const CWORKBOOK_SHEETS_LIMIT = 256
'Class variables
Private Enum HFIssueType
hfInline
hfShape
hfFrame
End Enum
Private Enum HFIssueLocation
hfHeader
hfFooter
End Enum
Private Type CellAtrributes
LineStyle As Integer
FillPattern As Integer
End Type
Private Type BadSheetNameChar
BadChar As String
Position As Integer
End Type
Private mAnalysis As DocumentAnalysis
Private mFileName As String
Const RID_STR_EXCEL_SUBISSUE_ERROR_TYPE = "ERROR.TYPE"
Const RID_STR_EXCEL_SUBISSUE_INFO = "INFO"
Const RID_STR_EXCEL_SUBISSUE_DATEDIF = "DATEDIF"
Const RID_STR_EXCEL_SUBISSUE_PHONETIC = "PHONETIC"
Const FontError = 94
Const CR_BADCHAR = "<TOKEN1>"
Const CR_BADCHARNUM = "<TOKEN2>"
Const DATA_SOURCE_EXCEL = 0
Const DATA_SOURCE_EXTERNAL = 1
Const DATA_SOURCE_MULTIPLE = 2
Const DATA_SOURCE_EXTERNAL_FILE = 3
Const C_MAX_CELL_RANGE_COUNT = 10000
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'***ADDING-ISSUE: Use Following Skeleton as Guideline for Adding Issue
' For complete list of all RID_STR_... for Issues (IssueType), SubIssues (SubType) and Attributes refer to:
' excel_res.bas and common_res.bas
'
' For complete list of all CID_... for Issue Categories(IssueID) and
' CSTR_... for XML Issues (IssueTypeXML) and XML SubIssues (SubTypeXML) refer to:
' ApplicationSpecific.bas and CommonMigrationAnalyser.bas
'
' You should not have to add any new Issue Categories or matching IssueTypes, only new SubIssues
Sub Analyze_SKELETON()
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_SKELETON"
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
With myIssue
.IssueID = CID_VBA_MACROS 'Issue Category
.IssueType = RID_STR_COMMON_ISSUE_VBA_MACROS 'Issue String
.SubType = RID_STR_COMMON_SUBISSUE_PROPERTIES 'SubIssue String
.Location = .CLocationDocument 'Location string
.IssueTypeXML = CSTR_ISSUE_VBA_MACROS 'Non localised XML Issue String
.SubTypeXML = CSTR_SUBISSUE_PROPERTIES 'Non localised XML SubIssue String
.locationXML = .CXMLLocationDocument 'Non localised XML location
.SubLocation = 0 'if not set will default to RID_STR_NOT_AVAILABLE_SHORTHAND
.Line = 0 'if not set will default to RID_STR_NOT_AVAILABLE_SHORTHAND
.column = 0 'if not set will default to RID_STR_NOT_AVAILABLE_SHORTHAND
' Add as many Attribute Value pairs as needed
' Note: following must always be true - Attributes.Count = Values.Count
.Attributes.Add "AAA"
.Values.Add "foobar"
' Use AddIssueDetailsNote to add notes to the Issue Details if required
' Public Sub AddIssueDetailsNote(myIssue As IssueInfo, noteNum As Long, noteStr As String, _
' Optional preStr As String = RID_STR_COMMON_NOTE_PRE)
' Where preStr is prepended to the output, with "Note" as the default
AddIssueDetailsNote myIssue, 0, RID_STR_COMMON_NOTE_DOCUMENT_PROPERTIES_LOST
mAnalysis.IssuesCountArray(CID_VBA_MACROS) = _
mAnalysis.IssuesCountArray(CID_VBA_MACROS) + 1
End With
mAnalysis.Issues.Add myIssue
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub DoAnalyse(fileName As String, userFormTypesDict As Scripting.Dictionary, _
startDir As String, storeToDir As String, fso As FileSystemObject)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "DoAnalyse"
'Dim secAutomation As MsoAutomationSecurity
'secAutomation = Application.AutomationSecurity
mAnalysis.name = fileName
Dim aWB As Workbook
mAnalysis.TotalIssueTypes = CTOTAL_CATEGORIES
'Make Excel run as non interactively as possible
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.Interactive = False
Application.AskToUpdateLinks = False
Application.EnableAnimations = False
Application.EnableSound = False
'Only supported in Office XP and above
'Application.AutomationSecurity = msoAutomationSecurityForceDisable
'mFileName = fso.GetFileName(fileName)
'WriteToLog "TmpDebug1", mFileName
Dim myPassword As String
myPassword = GetDefaultPassword
If myPassword = "" Then
myPassword = "xoxoxoxoxo"
End If
Set aWB = Workbooks.Open(fileName:=fileName, _
Password:=myPassword, _
WriteResPassword:=myPassword, _
UpdateLinks:=0)
'Application.AutomationSecurity = secAutomation
'Do Analysis
Analyze_Password_Protection aWB
Analyze_Workbook_Protection aWB
'Set Doc Properties
SetDocProperties mAnalysis, aWB, fso
Analyze_SheetLimits aWB
Analyze_SheetDisplay aWB
Analyze_SheetIssues aWB
Analyze_SheetCharts aWB
Analyze_WorkbookVersion aWB
Analyze_Macros mAnalysis, userFormTypesDict, aWB
' Doc Preparation only
' Save document with any fixed issues under <storeToDir>\prepared\<source doc name>
If mAnalysis.PreparableIssuesCount > 0 And CheckDoPrepare Then
Dim preparedFullPath As String
preparedFullPath = GetPreparedFullPath(mAnalysis.name, startDir, storeToDir, fso)
If preparedFullPath <> "" Then
If fso.FileExists(preparedFullPath) Then
fso.DeleteFile preparedFullPath, True
End If
If fso.FolderExists(fso.GetParentFolderName(preparedFullPath)) Then
If IsOldVersion(aWB.FileFormat) Then
aWB.SaveAs fileName:=preparedFullPath, FileFormat:=xlExcel9795
Else
aWB.SaveAs preparedFullPath
End If
End If
End If
End If
FinalExit:
If Not aWB Is Nothing Then
aWB.Close (False)
End If
Set aWB = Nothing
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.Interactive = True
Application.AskToUpdateLinks = True
Application.EnableAnimations = True
Application.EnableSound = True
'Debug - Call Sleep(5000)
Exit Sub
HandleErrors:
' MsgBox currentFunctionName & " : " & fileName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
' Handle Password error on Doc Open, Modify and Cancel
If Err.Number = 1004 Then
WriteDebug currentFunctionName & " : " & fileName & ": " & _
"User entered Invalid Document Password - " & Err.Number & " " & Err.Description & " " & Err.Source
HandleProtectedDocInvalidPassword mAnalysis, _
"User entered Invalid Document Password, further analysis not possible", fso
Resume FinalExit
End If
mAnalysis.Application = RID_STR_COMMON_CANNOT_OPEN
WriteDebug currentFunctionName & " : " & fileName & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub Analyze_SheetCharts(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_SheetCharts"
Dim myChartSheet As Chart
For Each myChartSheet In aWB.Charts
SetChartIssueMinor myChartSheet, myChartSheet.name, False
SetChartIssueComplex myChartSheet, myChartSheet.name
Next myChartSheet
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub Analyze_EmbeddedCharts(mySheet As Worksheet)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_EmbeddedCharts"
Dim BorderIssue As Boolean
Dim index As Integer
BorderIssue = False
Dim chartcount As Integer
Dim myChart As Chart
chartcount = mySheet.ChartObjects.count
For index = 1 To chartcount
BorderIssue = False
With mySheet.ChartObjects(index)
If .Border.LineStyle <> xlLineStyleNone Then
BorderIssue = True
End If
SetChartIssueMinor .Chart, mySheet.name, BorderIssue
'If Not ((.ChartType = xlSurface) _
' And (.ChartType = xlSurfaceTopViewWireframe) _
' And (.ChartType = xlSurfaceTopView)) Then
SetChartIssueComplex .Chart, mySheet.name
'End If
End With
Next index
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Private Function getType(o As Variant) As Integer
If (VarType(o) = vbString) Then
Dim aDataSource As String
aDataSource = o
getType = DATA_SOURCE_EXCEL
If (Len(aDataSource) > 0) Then
Dim nBackslashPos As Long
nBackslashPos = InStr(Trim(aDataSource), "\")
If (nBackslashPos > 0 And nBackslashPos < 4) Then
getType = DATA_SOURCE_EXTERNAL_FILE
End If
End If
ElseIf (IsArray(o)) Then
If (hasSecondDimension(o)) Then
getType = DATA_SOURCE_MULTIPLE
Else
getType = DATA_SOURCE_EXTERNAL
End If
End If
End Function
Private Function hasSecondDimension(o2 As Variant) As Boolean
On Error GoTo njet
Dim temp As Integer
temp = UBound(o2, 2)
hasSecondDimension = True
Exit Function
njet:
hasSecondDimension = False
End Function
Private Sub Analyze_PivotTable(myIssue As IssueInfo, myPivotTable As PivotTable)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyse_PivotTable"
Dim aPivotField As PivotField
Dim aNoteCount As Long
Dim bManualSort As Boolean
Dim bCalculatedValues As Boolean
Dim aSorting As XlSortOrder
Dim nCount As Integer
Dim nDataSource As Integer
bManualSort = False
bCalculatedValues = False
For Each aPivotField In myPivotTable.PivotFields
aSorting = xlAscending
On Error Resume Next 'some fields don't have any property at all
aSorting = aPivotField.AutoSortOrder
On Error GoTo HandleErrors
If (aSorting = xlManual) Then
bManualSort = True
End If
nCount = 0
On Error Resume Next 'some fields don't have any property at all
nCount = aPivotField.CalculatedItems.count
On Error GoTo HandleErrors
If (nCount > 0) Then
bCalculatedValues = True
End If
Next
nCount = 0
On Error Resume Next 'some fields don't have any property at all
nCount = myPivotTable.CalculatedFields.count
On Error GoTo HandleErrors
If (nCount > 0) Then
bCalculatedValues = True
End If
nDataSource = getType(myPivotTable.SourceData)
aNoteCount = 0
If (bManualSort) Then
AddIssueDetailsNote myIssue, aNoteCount, RID_RESXLT_COST_PIVOT_ManSort_Comment
aNoteCount = aNoteCount + 1
End If
If (nDataSource = DATA_SOURCE_EXTERNAL) Then
AddIssueDetailsNote myIssue, aNoteCount, RID_RESXLT_COST_PIVOT_ExternData_Comment
aNoteCount = aNoteCount + 1
ElseIf (nDataSource = DATA_SOURCE_MULTIPLE) Then
AddIssueDetailsNote myIssue, aNoteCount, RID_RESXLT_COST_PIVOT_MultConsRanges_Comment
aNoteCount = aNoteCount + 1
ElseIf (nDataSource = DATA_SOURCE_EXTERNAL_FILE) Then
Dim noteString As String
noteString = RID_RESXLT_COST_PIVOT_ExternData_Comment & "[" & _
myPivotTable.SourceData & "]"
AddIssueDetailsNote myIssue, aNoteCount, noteString
aNoteCount = aNoteCount + 1
End If
If (bCalculatedValues) Then
AddIssueDetailsNote myIssue, aNoteCount, RID_RESXLT_COST_PIVOT_CalcVal_Comment
aNoteCount = aNoteCount + 1
End If
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Private Sub SetChartIssueComplex(myChart As Chart, myName As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetChartIssueComplex"
Dim myIssue As IssueInfo
Dim bSeriesChartTypeChanged As Boolean
Dim bDatasourceNotLinkedtoCell As Boolean
Dim bDatasourceOnDifferentSheet As Boolean
Dim bCategoryandValue As Boolean
Dim bCLabelMorethanOneCell As Boolean
Dim bOneColumnRow As Boolean
Dim bDataTable As Boolean
Dim bXAxes As Boolean
Dim bseries As Boolean
Dim bformat As Boolean
Dim bpivot As Boolean
Set myIssue = New IssueInfo
bSeriesChartTypeChanged = False
bDatasourceNotLinkedtoCell = False
bDatasourceOnDifferentSheet = False
bCategoryandValue = False
bCLabelMorethanOneCell = False
bOneColumnRow = False
bDataTable = False
bXAxes = False
bformat = FormatIssueComplex(myChart, bDataTable, bXAxes)
bseries = SeriesIssue(myChart, bSeriesChartTypeChanged, bDatasourceNotLinkedtoCell, bDatasourceOnDifferentSheet, bCategoryandValue, bCLabelMorethanOneCell, bOneColumnRow)
bpivot = Not (myChart.PivotLayout Is Nothing)
If (Not (bseries Or bformat Or bpivot)) Then
GoTo FinalExit
ElseIf bpivot Then
With myIssue
.IssueID = CID_CHARTS_TABLES
.IssueType = RID_STR_EXCEL_ISSUE_CHARTS_AND_TABLES
.SubType = RID_STR_EXCEL_SUBISSUE_PIVOT
.Location = .CLocationSheet
.SubLocation = myName
.IssueTypeXML = CSTR_ISSUE_CHARTS_TABLES
.SubTypeXML = CSTR_SUBISSUE_CHART_PIVOT
.locationXML = .CXMLLocationSheet
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIVOT_TABLE_NAME
.Values.Add myChart.PivotLayout.PivotTable.name
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIVOT_FIELDS_VISIBLE
.Values.Add myChart.HasPivotFields
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIVOT_FIELDS_NUM
.Values.Add myChart.PivotLayout.PivotTable.PivotFields.count
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_TYPE
.Values.Add getChartTypeAsString(myChart.ChartType)
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_CHARTNAME
.Values.Add myChart.name
End With
AddIssueDetailsNote myIssue, 0, RID_RESXLT_COST_PIVOT_PivotChart_Comment
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) = _
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) + 1
mAnalysis.Issues.Add myIssue
GoTo FinalExit
Else
With myIssue
Dim NoteIndex As Long
NoteIndex = 0
.IssueID = CID_CHARTS_TABLES
.IssueType = RID_STR_EXCEL_ISSUE_CHARTS_AND_TABLES
.SubType = RID_STR_EXCEL_SUBISSUE_CHART_COMPLEX
.Location = .CLocationSheet
.SubLocation = myName
.IssueTypeXML = CSTR_ISSUE_CHARTS_TABLES
.SubTypeXML = CSTR_SUBISSUE_CHART_COMPLEX
.locationXML = .CXMLLocationSheet
If bDataTable Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_DATATABLE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_DATATABLE
NoteIndex = NoteIndex + 1
End If
If bXAxes Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_XAXISCATEGORY
.Values.Add RID_STR_EXCEL_ATTRIBUTE_TIMESCALE
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_XAXISCATEGORY
NoteIndex = NoteIndex + 1
End If
If bSeriesChartTypeChanged Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_SERIESCHARTTYPE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_CHANGED
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_SERIESCHARTTYPE
NoteIndex = NoteIndex + 1
End If
If bDatasourceNotLinkedtoCell Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_DATASOURCE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_DATASOURCENOTLINKEDTOCELL
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_DATASOURCENOTLINKEDTOCELL
NoteIndex = NoteIndex + 1
End If
If bDatasourceOnDifferentSheet Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_DATASOURCE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_DATASOURCEONDIFFERENTSHEET
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_DATASOURCEONDIFFERENTSHEET
NoteIndex = NoteIndex + 1
End If
If bCategoryandValue Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_CATEGORYANDDATA
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SEPARATE
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_CATEGORYANDDATA
NoteIndex = NoteIndex + 1
End If
If bCLabelMorethanOneCell Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_CATEGORYLABEL
.Values.Add RID_STR_EXCEL_ATTRIBUTE_CATEGORYLABELMORETHANONECELL
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_CATEGORYLABELMORETHANONECELL
NoteIndex = NoteIndex + 1
End If
If bOneColumnRow Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_COLUMNBAR
.Values.Add RID_STR_EXCEL_ATTRIBUTE_ONECOLUMNROW
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_COLUMNBAR
NoteIndex = NoteIndex + 1
End If
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_TYPE
.Values.Add getChartTypeAsString(myChart.ChartType)
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_CHARTNAME
.Values.Add myChart.name
End With
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) = _
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) + 1
mAnalysis.Issues.Add myIssue
End If
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Private Sub SetChartIssueMinor(myChart As Chart, myName As String, BorderIssue As Boolean)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetChartIssueMinor"
Dim myIssue As IssueInfo
Dim bUnsupportedType As Boolean
Dim bTrendline As Boolean
Dim bDatalabelWithLegend As Boolean
Dim bLegendPosition As Boolean
Dim bTitleFont As Boolean
Dim bPiechartDirection As Boolean
Dim bAxisInterval As Boolean
Set myIssue = New IssueInfo
bUnsupportedType = False
bTrendline = False
bDatalabelWithLegend = False
bLegendPosition = False
bTitleFont = False
bPiechartDirection = False
bAxisInterval = False
If (Not FormatissueMinor(myChart, bUnsupportedType, bTrendline, bDatalabelWithLegend, bLegendPosition, bTitleFont, bPiechartDirection, bAxisInterval)) And (Not BorderIssue) Then
GoTo FinalExit
Else
With myIssue
Dim NoteIndex As Long
NoteIndex = 0
.IssueID = CID_CHARTS_TABLES
.IssueType = RID_STR_EXCEL_ISSUE_CHARTS_AND_TABLES
.SubType = RID_STR_EXCEL_SUBISSUE_CHART_MINOR
.Location = .CLocationSheet
.SubLocation = myName
.IssueTypeXML = CSTR_ISSUE_CHARTS_TABLES
.SubTypeXML = CSTR_SUBISSUE_CHART_PIVOT
.locationXML = .CXMLLocationSheet
If bUnsupportedType Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_UNSUPPORTEDTYPE
.Values.Add getChartTypeAsString(myChart.ChartType)
' bubble chart
If (myChart.ChartType = xlBubble Or myChart.ChartType = xlBubble3DEffect) Then
AddIssueDetailsNote myIssue, NoteIndex, RID_RESXLT_COST_CHART_Bubble_Comment
' bar of pie and pie of pie chart
ElseIf (myChart.ChartType = xlPieOfPie Or myChart.ChartType = xlBarOfPie) Then
AddIssueDetailsNote myIssue, NoteIndex, RID_RESXLT_COST_CHART_BarOfPie_Comment
' Scatter chart
ElseIf (myChart.ChartType = xlXYScatter Or myChart.ChartType = xlXYScatterLines _
Or myChart.ChartType = xlXYScatterLinesNoMarkers _
Or myChart.ChartType = xlXYScatterSmooth _
Or myChart.ChartType = xlXYScatterSmoothNoMarkers) Then
AddIssueDetailsNote myIssue, NoteIndex, RID_RESXLT_COST_CHART_Scattered_Comment
' radar chart
ElseIf (myChart.ChartType = xlRadarMarkers Or myChart.ChartType = xlRadar) Then
AddIssueDetailsNote myIssue, NoteIndex, RID_RESXLT_COST_CHART_Radar_Comment
' radar filled chart
ElseIf (myChart.ChartType = xlRadarFilled) Then
AddIssueDetailsNote myIssue, NoteIndex, RID_RESXLT_COST_CHART_FilledRadar_Comment
' surface chart
ElseIf (myChart.ChartType = xlSurface Or myChart.ChartType = xlSurfaceTopView _
Or myChart.ChartType = xlSurfaceTopViewWireframe _
Or myChart.ChartType = xlSurfaceWireframe) Then
AddIssueDetailsNote myIssue, NoteIndex, RID_RESXLT_COST_CHART_Surface_Comment
Else
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_UNSUPPORTEDTYPE1
NoteIndex = NoteIndex + 1
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_UNSUPPORTEDTYPE2
End If
NoteIndex = NoteIndex + 1
End If
If bTrendline Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_TRENDLINE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_TRENDLINE
NoteIndex = NoteIndex + 1
End If
If bDatalabelWithLegend Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_DATALABELWITHLEGEND
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_DATALABELWITHLEGEND
NoteIndex = NoteIndex + 1
End If
If bLegendPosition Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_LEGENDPOSITION
.Values.Add RID_STR_EXCEL_ATTRIBUTE_NOTRIGHT
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_LEGENDPOSITION
NoteIndex = NoteIndex + 1
End If
If bTitleFont Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_TITLEFONT
.Values.Add RID_STR_EXCEL_ATTRIBUTE_DIFFERENT
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_TITLEFONT
NoteIndex = NoteIndex + 1
End If
If bPiechartDirection Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SLICES_IN_DIFFERENT_DIRECTION
End If
If BorderIssue Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_BORDER
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_BORDER
NoteIndex = NoteIndex + 1
End If
If bAxisInterval Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_AXISINTERVAL
.Values.Add RID_STR_EXCEL_ATTRIBUTE_AUTO
AddIssueDetailsNote myIssue, NoteIndex, RID_STR_EXCEL_NOTE_AXISINTERVAL
NoteIndex = NoteIndex + 1
End If
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_CHARTNAME
.Values.Add myChart.name
End With
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) = _
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) + 1
mAnalysis.Issues.Add myIssue
End If
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetChartIssue(myChart As Chart, myName As String, strSubType As String, _
strXMLSubType As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetChartIssue"
Dim myIssue As IssueInfo
Dim bUnsupportedPosition As Boolean
Set myIssue = New IssueInfo
' Common Settings
With myIssue
.IssueID = CID_CHARTS_TABLES
.IssueType = RID_STR_EXCEL_ISSUE_CHARTS_AND_TABLES
.SubType = strSubType
.Location = .CLocationSheet
.SubLocation = myName
.IssueTypeXML = CSTR_ISSUE_CHARTS_TABLES
.SubTypeXML = strXMLSubType
.locationXML = .CXMLLocationSheet
If myChart.HasTitle Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_TITLE
.Values.Add myChart.chartTitle.Text
End If
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_TYPE
.Values.Add myChart.ChartType 'TBD - getChartTypeAsString() convert to String
'Pie Chart
If (myChart.ChartType = xlPie) Or _
(myChart.ChartType = xlPieExploded) Or _
(myChart.ChartType = xlPieOfPie) Or _
(myChart.ChartType = xl3DPie) Or _
(myChart.ChartType = xl3DPieExploded) Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SLICES_IN_DIFFERENT_DIRECTION
End If
If Not myChart.PivotLayout Is Nothing Then
'Pivot Chart
.SubType = RID_STR_EXCEL_SUBISSUE_PIVOT & " " & strSubType
'Pivot Chart details
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIVOT_TABLE_NAME
.Values.Add myChart.PivotLayout.PivotTable.name
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIVOT_FIELDS_VISIBLE
.Values.Add myChart.HasPivotFields
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PIVOT_FIELDS_NUM
.Values.Add myChart.PivotLayout.PivotTable.PivotFields.count
End If
End With
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) = _
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) + 1
mAnalysis.Issues.Add myIssue
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function getLineStyleAsString(myLineStyle As XlLineStyle) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getLineStyleAsString"
Dim strVal As String
Select Case myLineStyle
Case xlContinuous
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_CONTINUOUS
Case xlDash
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_DASH
Case xlDashDot
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_DASHDOT
Case xlDot
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_DOT
Case xlDouble
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_DOUBLE
Case xlSlantDashDot
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_SLANTDASHDOT
Case xlLineStyleNone
strVal = RID_STR_EXCEL_ENUMERATION_LINE_STYLE_LINESTYLENONE
Case Else
strVal = RID_STR_EXCEL_ENUMERATION_UNKNOWN
End Select
getLineStyleAsString = strVal
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Function getChartTypeAsString(myChartType As XlChartType) As String
'*********************************************************
'**** Localisation: ON HOLD ******************************
'*********************************************************
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getChartTypeAsString"
Dim strVal As String
Select Case myChartType
Case xl3DArea
strVal = "3DArea"
Case xl3DAreaStacked
strVal = "3DAreaStacked"
Case xl3DAreaStacked100
strVal = "3DAreaStacked100"
Case xl3DBarClustered
strVal = "3DBarClustered"
Case xl3DBarStacked
strVal = "xl3DBarStacked"
Case xl3DBarStacked100
strVal = "xl3DBarStacked100"
Case xl3DColumn
strVal = "3DColumn"
Case xl3DColumnClustered
strVal = "xl3DColumnClustered"
Case xl3DColumnStacked
strVal = "xl3DColumnStacked"
Case xl3DColumnStacked100
strVal = "xl3DColumnStacked100"
Case xl3DLine
strVal = "3DLine"
Case xl3DPie
strVal = "3DPie"
Case xl3DPieExploded
strVal = "3DPieExploded"
Case xlArea
strVal = "Area"
Case xlAreaStacked
strVal = "AreaStacked"
Case xlAreaStacked100
strVal = "AreaStacked100"
Case xlBarClustered
strVal = "BarClustered"
Case xlBarOfPie
strVal = "BarOfPie"
Case xlBarStacked
strVal = "BarStacked"
Case xlBarStacked100
strVal = "BarStacked100"
Case xlBubble
strVal = "Bubble"
Case xlBubble3DEffect
strVal = "Bubble3DEffect"
Case xlColumnClustered
strVal = "ColumnClustered"
Case xlColumnStacked
strVal = "ColumnStacked"
Case xlColumnStacked100
strVal = "ColumnStacked100"
Case xlConeBarClustered
strVal = "ConeBarClustered"
Case xlConeBarStacked
strVal = "ConeBarStacked"
Case xlConeBarStacked100
strVal = "ConeBarStacked100"
Case xlConeCol
strVal = "ConeCol"
Case xlConeColClustered
strVal = "ConeColClustered"
Case xlConeColStacked
strVal = "ConeColStacked"
Case xlConeColStacked100
strVal = "ConeColStacked100"
Case xlCylinderBarClustered
strVal = "CylinderBarClustered"
Case xlCylinderBarStacked
strVal = "CylinderBarStacked"
Case xlCylinderBarStacked100
strVal = "CylinderBarStacked100"
Case xlCylinderCol
strVal = "CylinderCol"
Case xlCylinderColClustered
strVal = "CylinderColClustered"
Case xlCylinderColStacked
strVal = "CylinderColStacked"
Case xlCylinderColStacked100
strVal = "CylinderColStacked100"
Case xlDoughnut
strVal = "Doughnut"
Case xlLine
strVal = "Line"
Case xlLineMarkers
strVal = "LineMarkers"
Case xlLineMarkersStacked
strVal = "LineMarkersStacked"
Case xlLineMarkersStacked100
strVal = "LineMarkersStacked100"
Case xlLineStacked
strVal = "LineStacked"
Case xlLineStacked100
strVal = "LineStacked100"
Case xlPie
strVal = "Pie"
Case xlPieExploded
strVal = "PieExploded"
Case xlPieOfPie
strVal = "PieOfPie"
Case xlPyramidBarClustered
strVal = "PyramidBarClustered"
Case xlPyramidBarStacked
strVal = "PyramidBarStacked"
Case xlPyramidBarStacked100
strVal = "PyramidBarStacked100"
Case xlPyramidCol
strVal = "PyramidCol"
Case xlPyramidColClustered
strVal = "PyramidColClustered"
Case xlPyramidColStacked
strVal = "PyramidColStacked"
Case xlPyramidColStacked100
strVal = "PyramidColStacked100"
Case xlRadar
strVal = "Radar"
Case xlRadarFilled
strVal = "RadarFilled"
Case xlRadarMarkers
strVal = "RadarMarkers"
Case xlStockHLC
strVal = "StockHLC"
Case xlStockOHLC
strVal = "StockOHLC"
Case xlStockVHLC
strVal = "StockVHLC"
Case xlStockVOHLC
strVal = "StockVOHLC"
Case xlSurface
strVal = "Surface"
Case xlSurfaceTopView
strVal = "SurfaceTopView"
Case xlSurfaceTopViewWireframe
strVal = "SurfaceTopViewWireframe"
Case xlSurfaceWireframe
strVal = "SurfaceWireframe"
Case xlXYScatter
strVal = "XYScatter"
Case xlXYScatterLines
strVal = "XYScatterLines"
Case xlXYScatterLinesNoMarkers
strVal = "XYScatterLinesNoMarkers"
Case xlXYScatterSmooth
strVal = "XYScatterSmooth"
Case xlXYScatterSmoothNoMarkers
strVal = "XYScatterSmoothNoMarkers"
Case Else
strVal = RID_STR_EXCEL_ENUMERATION_UNKNOWN
End Select
getChartTypeAsString = strVal
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Sub HandleZoomIssue(currentSheet)
Dim myIssue As IssueInfo
Dim currentFunctionName As String
currentFunctionName = "HandleZoomIssue"
On Error GoTo HandleErrors
Set myIssue = New IssueInfo
With myIssue
.IssueID = CID_FORMAT
.IssueType = RID_STR_EXCEL_ISSUE_FORMAT
.SubType = RID_STR_EXCEL_SUBISSUE_ZOOM
.Location = .CLocationSheet
.SubLocation = currentSheet.name
.IssueTypeXML = CSTR_ISSUE_FORMAT
.SubTypeXML = CSTR_SUBISSUE_ZOOM
.locationXML = .CXMLLocationSheet
AddIssueDetailsNote myIssue, 0, RID_STR_EXCEL_NOTE_ZOOM
End With
mAnalysis.IssuesCountArray(CID_FORMAT) = _
mAnalysis.IssuesCountArray(CID_FORMAT) + 1
mAnalysis.Issues.Add myIssue
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub Analyze_SheetDisplay(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_SheetDisplay"
If aWB.Sheets.count = 1 Then Exit Sub
Dim lastZoomVal As Integer
Dim bInitZoom As Boolean
Dim bZoomChanged As Boolean
Dim ws As Object
bInitZoom = True
bZoomChanged = False
For Each ws In aWB.Sheets
ws.Activate
On Error GoTo HandleErrors
If bInitZoom Then
lastZoomVal = ActiveWindow.Zoom
bInitZoom = False
ElseIf Not bZoomChanged Then
If ActiveWindow.Zoom <> lastZoomVal Then
bZoomChanged = True
HandleZoomIssue ws
End If
End If
If bZoomChanged Then Exit For
Next ws
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub Analyze_SheetLimits(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_SheetLimits"
Dim myIssue As IssueInfo
If aWB.Sheets.count < CWORKBOOK_SHEETS_LIMIT + 1 Then Exit Sub
Set myIssue = New IssueInfo
With myIssue
.IssueID = CID_CONTENT_AND_DOCUMENT_PROPERTIES
.IssueType = RID_STR_COMMON_ISSUE_CONTENT_AND_DOCUMENT_PROPERTIES
.SubType = RID_STR_EXCEL_SUBISSUE_MAX_SHEETS_EXCEEDED
.Location = .CLocationWorkBook
.SubLocation = aWB.name
.IssueTypeXML = CSTR_ISSUE_CONTENT_DOCUMENT_PROPERTIES
.SubTypeXML = CSTR_SUBISSUE_MAX_SHEETS_EXCEEDED
.locationXML = .CXMLLocationWorkBook
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_NUMBER_OF_SHEETS
.Values.Add aWB.Sheets.count
AddIssueDetailsNote myIssue, 0, RID_STR_EXCEL_NOTE_SHEET_LIMITS_1 & CWORKBOOK_SHEETS_LIMIT
AddIssueDetailsNote myIssue, 1, RID_STR_EXCEL_NOTE_SHEET_LIMITS_2 & CWORKBOOK_SHEETS_LIMIT
End With
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) = _
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) + 1
mAnalysis.Issues.Add myIssue
Set myIssue = Nothing
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub Analyze_SheetIssues(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_SheetIssues"
Dim myWrkSheet As Worksheet
For Each myWrkSheet In aWB.Worksheets
Analyze_OLEEmbedded myWrkSheet
Analyze_CellInSheetIssues myWrkSheet
Analyze_EmbeddedCharts myWrkSheet
Analyze_SheetName myWrkSheet
Analyze_QueryTables myWrkSheet
Next myWrkSheet
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub Analyze_SheetName(mySheet As Worksheet)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_SheetName"
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
Dim invalidCharacters As String
invalidCharacters = InvalidSheetNameCharacters(mySheet.name)
If Len(invalidCharacters) <> 0 Then
With myIssue
.IssueID = CID_CONTENT_AND_DOCUMENT_PROPERTIES
.IssueType = RID_STR_COMMON_ISSUE_CONTENT_AND_DOCUMENT_PROPERTIES
.SubType = RID_STR_EXCEL_SUBISSUE_INVALID_WORKSHEET_NAME
.Location = .CLocationSheet
.SubLocation = mySheet.name
.IssueTypeXML = CSTR_ISSUE_CONTENT_DOCUMENT_PROPERTIES
.SubTypeXML = CSTR_SUBISSUE_INVALID_WORKSHEET_NAME
.locationXML = .CXMLLocationSheet
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_INVALIDCHARACTER
.Values.Add invalidCharacters
AddIssueDetailsNote myIssue, 0, RID_STR_EXCEL_NOTE_INVALIDWORKSHEETNAME
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) = _
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) + 1
End With
mAnalysis.Issues.Add myIssue
End If
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function InvalidSheetNameCharacters(aName As String) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "InvalidSheetNameCharacters"
Dim I As Integer
Dim NameCount As Integer
Dim newBadCharLine As String
Dim invalidCharacterDetails As String
Dim BadCharPosition As String
Dim theBadChars As BadSheetNameChar
NameCount = Len(aName)
invalidCharacterDetails = ""
For I = 1 To NameCount
theBadChars.BadChar = Mid(aName, I, 1)
theBadChars.Position = I
BadCharPosition = CStr(theBadChars.Position)
Select Case theBadChars.BadChar
Case "[", "]", "{", "}", ".", "!", "%", "$", "^", ".", "&", "(", ")", _
"-", "=", "+", "~", "#", "@", "'", ";", "<", ">", ",", "|", "`"
newBadCharLine = ReplaceTopic2Tokens(RID_STR_EXCEL_ATTRIBUTE_BADCHARACTER, CR_BADCHAR, _
theBadChars.BadChar, CR_BADCHARNUM, BadCharPosition)
invalidCharacterDetails = invalidCharacterDetails + newBadCharLine + ", "
Case Else
End Select
Next I
If Len(invalidCharacterDetails) > 0 Then
InvalidSheetNameCharacters = Left(invalidCharacterDetails, (Len(invalidCharacterDetails) - 2))
Else
InvalidSheetNameCharacters = ""
End If
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Sub Analyze_QueryTables(mySheet As Worksheet)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_QueryTables"
Dim aTable As QueryTable
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
For Each aTable In mySheet.QueryTables
If (aTable.QueryType = xlADORecordset) Or _
(aTable.QueryType = xlDAORecordSet) Or _
(aTable.QueryType = xlODBCQuery) Or _
(aTable.QueryType = xlOLEDBQuery) Then
With myIssue
.IssueID = CID_CHARTS_TABLES
.IssueType = RID_STR_EXCEL_ISSUE_CHARTS_AND_TABLES
.SubType = RID_RESXLS_COST_DB_Query
.Location = .CLocationSheet
.SubLocation = mySheet.name
.IssueTypeXML = CSTR_ISSUE_CHARTS_TABLES
.SubTypeXML = CSTR_SUBISSUE_DB_QUERY
.locationXML = .CXMLLocationSheet
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_DB_QUERY
.Values.Add aTable.Connection
AddIssueDetailsNote myIssue, 0, RID_STR_EXCEL_NOTE_DB_QUERY
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) = _
mAnalysis.IssuesCountArray(CID_CHARTS_TABLES) + 1
End With
mAnalysis.Issues.Add myIssue
End If
Next aTable
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub Analyze_WorkbookVersion(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_WorkbookVersion"
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
Dim aProp As Variant
If IsOldVersion(aWB.FileFormat) Then
With myIssue
.IssueID = CID_CONTENT_AND_DOCUMENT_PROPERTIES
.IssueType = RID_STR_COMMON_ISSUE_CONTENT_AND_DOCUMENT_PROPERTIES
.SubType = RID_STR_EXCEL_SUBISSUE_OLD_WORKBOOK_VERSION
.Location = .CLocationWorkBook
.IssueTypeXML = CSTR_ISSUE_CONTENT_DOCUMENT_PROPERTIES
.SubTypeXML = CSTR_SUBISSUE_OLD_WORKBOOK_VERSION
.locationXML = .CXMLLocationWorkBook
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_WORKBOOK_VERSION
.Values.Add aWB.FileFormat
AddIssueDetailsNote myIssue, 0, RID_STR_EXCEL_NOTE_OLDWORKBOOKVERSION
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) = _
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) + 1
End With
Call DoPreparation(mAnalysis, myIssue, RID_STR_EXCEL_NOTE_OLD_OLDWORKBOOKVERSION_PREPARABLE, aProp, aWB)
mAnalysis.Issues.Add myIssue
End If
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Function getRange(myRange As Range) As String
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "getRange"
getRange = ""
On Error Resume Next
getRange = myRange.Address(RowAbsolute:=False, ColumnAbsolute:=False, ReferenceStyle:=xlA1)
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : myRange.name " & myRange.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Sub Analyze_CellInSheetIssues(mySheet As Worksheet)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_CellInSheetIssues"
Dim myCellRng As Range
Set myCellRng = mySheet.UsedRange
Call CheckAllCellFormatting(myCellRng, mySheet.name)
Call CheckAllCellFunctions(myCellRng, mySheet.name)
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub CheckAllCellFormatting(CurrRange As Range, myName As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "CheckAllCellFormatting"
Dim myCell As Range
Dim myCellAttri As CellAtrributes
Dim bCellIssue As Boolean
Dim bCellIssueAll As Boolean
Dim startTime As Single
bCellIssue = False
bCellIssueAll = False
startTime = Timer
For Each myCell In CurrRange
bCellIssue = CheckCellFormatting(myCell, myCellAttri)
bCellIssueAll = bCellIssueAll Or bCellIssue
If (Timer - gExcelMaxRangeProcessTime > startTime) Then
WriteDebug currentFunctionName & " : [" & myName & _
"]Too much time needed, abortet cell formatting check."
Exit For
End If
Next
FinalExit:
If bCellIssueAll Then
ReportCellFormattingIssue myName, myCellAttri
End If
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Function CheckLineFormatIssue(myRange As Range, edge As XlBordersIndex) As Boolean
CheckLineFormatIssue = (myRange.Borders(edge).LineStyle <> xlContinuous) And _
(myRange.Borders(edge).LineStyle <> xlDouble) And _
(myRange.Borders(edge).LineStyle <> xlLineStyleNone)
End Function
Private Function CheckCellFormatting(myCell As Range, myCellAttri As CellAtrributes) As Boolean
Dim currentFunctionName As String
currentFunctionName = "CheckCellFormatting"
On Error GoTo HandleErrors
Dim bCellLineFormatIssue As Boolean
CheckCellFormatting = False
bCellLineFormatIssue = CheckLineFormatIssue(myCell, xlEdgeBottom) Or _
CheckLineFormatIssue(myCell, xlEdgeLeft) Or _
CheckLineFormatIssue(myCell, xlEdgeRight) Or _
CheckLineFormatIssue(myCell, xlEdgeTop)
CheckCellFormatting = bCellLineFormatIssue Or _
(myCell.Interior.Pattern <> xlPatternSolid And myCell.Interior.Pattern <> xlPatternNone)
If Not CheckCellFormatting Then Exit Function
If bCellLineFormatIssue Then
myCellAttri.LineStyle = myCellAttri.LineStyle + 1
End If
If (myCell.Interior.Pattern <> xlPatternSolid And myCell.Interior.Pattern <> xlPatternNone) Then
myCellAttri.FillPattern = myCellAttri.FillPattern + 1
End If
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Sub ReportCellFormattingIssue(myName As String, myCellAttri As CellAtrributes)
Dim currentFunctionName As String
currentFunctionName = "ReportCellFormattingIssue"
On Error GoTo HandleErrors
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
With myIssue
.IssueID = CID_FORMAT
.IssueType = RID_STR_EXCEL_ISSUE_FORMAT
.SubType = RID_STR_EXCEL_SUBISSUE_ATTRIBUTES
.Location = .CLocationSheet
.IssueTypeXML = CSTR_ISSUE_FORMAT
.SubTypeXML = CSTR_SUBISSUE_ATTRIBUTES
.locationXML = .CXMLLocationSheet
.SubLocation = myName
'.Line = myCell.row
'.column = Chr(myCell.column + 65 - 1)
Dim noteCount As Long
noteCount = 0
If myCellAttri.LineStyle > 0 Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_LINE_STYLE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_DASHED_DOT
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_NUMBER_OF_CELLS
.Values.Add myCellAttri.LineStyle
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_ATTRIBUTES_3
noteCount = noteCount + 1
End If
If myCellAttri.FillPattern > 0 Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_FILL_PATTERN
.Values.Add RID_STR_EXCEL_ATTRIBUTE_PATTERNED
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_NUMBER_OF_CELLS
.Values.Add myCellAttri.FillPattern
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_ATTRIBUTES_4
noteCount = noteCount + 1
End If
mAnalysis.IssuesCountArray(CID_FORMAT) = _
mAnalysis.IssuesCountArray(CID_FORMAT) + 1
End With
mAnalysis.Issues.Add myIssue
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub CheckAllCellFunctions(CurrRange As Range, myName As String)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "CheckAllCellFunctions"
Dim myCell As Range
Dim startTime As Single
startTime = Timer
For Each myCell In CurrRange
Call CheckCellFunction(myCell, myName)
If (Timer - gExcelMaxRangeProcessTime > startTime) Then
WriteDebug currentFunctionName & " : [" & myName & _
"]Too much time needed, abortet cell functions check (xlCellTypeFormulas)."
Exit For
End If
Next
FinalExit:
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub CheckCellFunction(myCell As Range, myName As String)
Dim currentFunctionName As String
currentFunctionName = "CheckCellFunction"
On Error GoTo HandleErrors
Dim bCellFunctionIssue As Boolean
Dim bCellINFOFunctionIssue As Boolean
Dim bCellERROR_TYPEFunctionIssue As Boolean
Dim bCellExternalFunctionIssue As Boolean
Dim bHasDateDifFunction As Boolean
Dim bHasPhoneticFunction As Boolean
Dim aFormularStr As String
aFormularStr = myCell.FormulaR1C1
If (aFormularStr = Null) Then Exit Sub
If (aFormularStr = "") Then Exit Sub
bCellINFOFunctionIssue = (InStr(aFormularStr, "INFO(") <> 0)
bCellERROR_TYPEFunctionIssue = (InStr(aFormularStr, "ERROR.TYPE(") <> 0)
bCellExternalFunctionIssue = (InStr(aFormularStr, ".xls!") <> 0)
bHasDateDifFunction = (InStr(aFormularStr, "DATEDIF(") <> 0)
bHasPhoneticFunction = (InStr(aFormularStr, "PHONETIC(") <> 0)
bCellFunctionIssue = bCellINFOFunctionIssue Or bCellERROR_TYPEFunctionIssue _
Or bCellExternalFunctionIssue Or bHasDateDifFunction Or bHasPhoneticFunction
If Not bCellFunctionIssue Then Exit Sub
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
With myIssue
.IssueID = CID_FUNCTIONS
.IssueType = RID_STR_EXCEL_ISSUE_FUNCTIONS
.Location = .CLocationSheet
.IssueTypeXML = CSTR_ISSUE_FUNCTIONS
.locationXML = .CXMLLocationSheet
.SubLocation = myName
.Line = myCell.row
.column = Chr(myCell.column + 65 - 1)
Dim noteCount As Long
noteCount = 0
If bCellINFOFunctionIssue Then
.SubTypeXML = CSTR_SUBISSUE_INFO
.SubType = RID_STR_EXCEL_SUBISSUE_INFO
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_FUNCTION_STRING
.Values.Add myCell.FormulaR1C1
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_FUNCTIONS_1
noteCount = noteCount + 1
End If
If bCellERROR_TYPEFunctionIssue Then
.SubTypeXML = CSTR_SUBISSUE_ERROR_TYPE
.SubType = RID_STR_EXCEL_SUBISSUE_ERROR_TYPE
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_FUNCTION_STRING
.Values.Add myCell.FormulaR1C1
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_FUNCTIONS_2
noteCount = noteCount + 1
End If
If bCellExternalFunctionIssue Then
.SubTypeXML = CSTR_SUBISSUE_EXTERNAL
.SubType = RID_STR_EXCEL_SUBISSUE_EXTERNAL
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_FUNCTION_STRING
.Values.Add myCell.FormulaR1C1
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_FUNCTIONS_3
noteCount = noteCount + 1
End If
If bHasDateDifFunction Then
.SubTypeXML = CSTR_SUBISSUE_DATEDIF
.SubType = RID_STR_EXCEL_SUBISSUE_DATEDIF
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_FUNCTION_STRING
.Values.Add myCell.FormulaR1C1
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_FUNCTIONS_DATEDIF
noteCount = noteCount + 1
End If
If bHasPhoneticFunction Then
.SubTypeXML = CSTR_SUBISSUE_PHONETIC
.SubType = RID_STR_EXCEL_SUBISSUE_PHONETIC
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_FUNCTION_STRING
.Values.Add myCell.FormulaR1C1
AddIssueDetailsNote myIssue, noteCount, RID_STR_EXCEL_NOTE_CELL_FUNCTIONS_PHONETIC
noteCount = noteCount + 1
End If
mAnalysis.IssuesCountArray(CID_FUNCTIONS) = _
mAnalysis.IssuesCountArray(CID_FUNCTIONS) + 1
End With
mAnalysis.Issues.Add myIssue
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub Analyze_Password_Protection(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_Password_Protection"
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
If aWB.HasPassword Or aWB.WriteReserved Then
With myIssue
.IssueID = CID_CONTENT_AND_DOCUMENT_PROPERTIES
.IssueType = RID_STR_COMMON_ISSUE_CONTENT_AND_DOCUMENT_PROPERTIES
.SubType = RID_STR_COMMON_SUBISSUE_PASSWORDS_PROTECTION
.IssueTypeXML = CSTR_ISSUE_CONTENT_DOCUMENT_PROPERTIES
.SubTypeXML = CSTR_SUBISSUE_PASSWORD_PROTECTION
.locationXML = .CLocationWorkBook
.Location = .CLocationWorkBook
If aWB.HasPassword Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PASSWORD_TO_OPEN
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
End If
If aWB.WriteReserved Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PASSWORD_TO_MODIFY
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
End If
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) = _
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) + 1
End With
mAnalysis.Issues.Add myIssue
End If
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub SetDocProperties(docAnalysis As DocumentAnalysis, wb As Workbook, fso As FileSystemObject)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SetProperties"
Dim f As File
Set f = fso.GetFile(docAnalysis.name)
Const appPropertyAppName = 9
Const appPropertyLastAuthor = 7
Const appPropertyRevision = 8
Const appPropertyTemplate = 6
Const appPropertyTimeCreated = 11
Const appPropertyTimeLastSaved = 12
On Error Resume Next
docAnalysis.PageCount = wb.Sheets.count
docAnalysis.Created = f.DateCreated
docAnalysis.Modified = f.DateLastModified
docAnalysis.Accessed = f.DateLastAccessed
docAnalysis.Printed = DateValue("01/01/1900")
On Error GoTo HandleErrors
On Error Resume Next 'Some apps may not support all props
docAnalysis.Application = getAppSpecificApplicationName & " " & Application.Version
'docAnalysis.Application = wb.BuiltinDocumentProperties(appPropertyAppName)
'If InStr(docAnalysis.Application, "Microsoft") = 1 Then
' docAnalysis.Application = Mid(docAnalysis.Application, Len("Microsoft") + 2)
'End If
'If InStr(Len(docAnalysis.Application) - 2, docAnalysis.Application, ".") = 0 Then
' docAnalysis.Application = docAnalysis.Application & " " & Application.Version
'End If
docAnalysis.SavedBy = _
wb.BuiltinDocumentProperties(appPropertyLastAuthor)
docAnalysis.Revision = _
val(wb.BuiltinDocumentProperties(appPropertyRevision))
docAnalysis.Template = _
fso.GetFileName(wb.BuiltinDocumentProperties(appPropertyTemplate))
docAnalysis.Modified = _
wb.BuiltinDocumentProperties(appPropertyTimeLastSaved)
FinalExit:
Set f = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Sub Analyze_OLEEmbedded(wrkSheet As Worksheet)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_OLEEmbedded"
' Handle Shapes
Dim aShape As Shape
For Each aShape In wrkSheet.Shapes
Analyze_OLEEmbeddedSingleShape mAnalysis, aShape, wrkSheet.name
Analyze_Lines mAnalysis, aShape, wrkSheet.name
Analyze_Transparency mAnalysis, aShape, wrkSheet.name
Analyze_Gradients mAnalysis, aShape, wrkSheet.name
Next aShape
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Sub
Sub Analyze_Workbook_Protection(aWB As Workbook)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Analyze_Workbook_Protection"
Dim myIssue As IssueInfo
Set myIssue = New IssueInfo
Dim bProtectSharing As Boolean
Dim bProtectStructure As Boolean
Dim bProtectWindows As Boolean
bProtectSharing = False
bProtectStructure = False
bProtectWindows = False
If Not WorkbookProtectTest(aWB, bProtectSharing, bProtectStructure, bProtectWindows) Then
GoTo FinalExit
End If
Set myIssue = New IssueInfo
With myIssue
.IssueID = CID_CONTENT_AND_DOCUMENT_PROPERTIES
.IssueType = RID_STR_COMMON_ISSUE_CONTENT_AND_DOCUMENT_PROPERTIES
.SubType = RID_STR_EXCEL_SUBISSUE_WORKBOOK_PROTECTION
.Location = .CLocationWorkBook
.IssueTypeXML = CSTR_ISSUE_CONTENT_DOCUMENT_PROPERTIES
.SubTypeXML = CSTR_SUBISSUE_WORKBOOK_PROTECTION
.locationXML = .CXMLLocationWorkBook
If bProtectSharing Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PROTECT_TYPE_SHARING
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
End If
If bProtectStructure Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PROTECT_TYPE_STRUCTURE
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
End If
If bProtectWindows Then
.Attributes.Add RID_STR_EXCEL_ATTRIBUTE_PROTECT_TYPE_WINDOWS
.Values.Add RID_STR_EXCEL_ATTRIBUTE_SET
End If
AddIssueDetailsNote myIssue, 0, RID_STR_EXCEL_NOTE_PASSWORD_TO_OPEN
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) = _
mAnalysis.IssuesCountArray(CID_CONTENT_AND_DOCUMENT_PROPERTIES) + 1
End With
mAnalysis.Issues.Add myIssue
FinalExit:
Set myIssue = Nothing
Exit Sub
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Sub
Private Function WorkbookProtectTest(aWB As Workbook, bProtectSharing As Boolean, _
bProtectStructure As Boolean, bProtectWindows As Boolean) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "WorkbookProtectTest"
WorkbookProtectTest = False
On Error Resume Next 'Simulate Try Catch
aWB.UnprotectSharing sharingPassword:=" "
If Err.Number = 1004 Then
bProtectSharing = True
ElseIf Err.Number <> 0 Then
Resume HandleErrors
End If
On Error GoTo HandleErrors
On Error Resume Next 'Simulate Try Catch
aWB.Unprotect Password:=""
If Err.Number = 1004 Then
If aWB.ProtectStructure = True Then
bProtectStructure = True
End If
If aWB.ProtectWindows = True Then
bProtectWindows = True
End If
End If
If bProtectSharing Or bProtectStructure Or bProtectWindows Then
WorkbookProtectTest = True
End If
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Private Sub Class_Initialize()
Set mAnalysis = New DocumentAnalysis
End Sub
Private Sub Class_Terminate()
Set mAnalysis = Nothing
End Sub
Public Property Get Results() As DocumentAnalysis
Set Results = mAnalysis
End Property
Private Function FormatIssueComplex(myChart As Chart, bDataTable As Boolean, bXAxes As Boolean) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "FormatIssueComplex"
bXAxes = False
If myChart.HasDataTable Then
bDataTable = True
End If
If Not (IsPie(myChart) Or myChart.ChartType = xlDoughnut Or myChart.ChartType = xlBubble3DEffect) Then
If myChart.HasAxis(1) Then
If myChart.Axes(1).CategoryType = xlTimeScale Or myChart.Axes(1).CategoryType = xlAutomaticScale Then
bXAxes = True
End If
End If
End If
If bDataTable Or bXAxes Then
FormatIssueComplex = True
End If
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Function IsAreaChart(myChart As Chart) As Boolean
If (myChart.ChartType = xlArea Or myChart.ChartType = xl3DArea Or _
myChart.ChartType = xlAreaStacked Or _
myChart.ChartType = xl3DAreaStacked Or _
myChart.ChartType = xlAreaStacked100 Or _
myChart.ChartType = xl3DAreaStacked100) _
Then
IsAreaChart = True
Else
IsAreaChart = False
End If
End Function
Private Function FormatissueMinor(myChart As Chart, bUnsupportedType As Boolean, bTrendline As Boolean, bDatalabelWithLegend As Boolean, bLegendPosition As Boolean, bTitleFont As Boolean, bPiechartDirection As Boolean, bAxisInterval As Boolean) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "FormatissueMinor"
Dim ctype As Integer
Dim fsize As Integer
Dim se As Series
Dim dl As DataLabel
FormatissueMinor = False
ctype = myChart.ChartType
If (ctype = xlBubble Or ctype = xlPieOfPie Or ctype = xl3DPieExploded _
Or ctype = xlRadarFilled Or ctype = xlBubble3DEffect _
Or ctype = xlRadarMarkers Or ctype = xlRadar Or ctype = xlBarOfPie _
Or ctype = xlXYScatter Or ctype = xlXYScatterLines Or ctype = xlXYScatterLinesNoMarkers _
Or ctype = xlXYScatterSmooth Or ctype = xlXYScatterSmoothNoMarkers _
Or ctype = xlSurface Or ctype = xlSurfaceTopView Or ctype = xlSurfaceTopViewWireframe _
Or ctype = xlSurfaceWireframe) Then
bUnsupportedType = True
End If
For Each se In myChart.SeriesCollection
On Error Resume Next ' may not have trendlines property
If se.Trendlines.count <> 0 Then
If Err.Number = 0 Then
bTrendline = True
End If
End If
If se.HasDataLabels Then
If Err.Number = 0 Then
If (IsAreaChart(myChart)) Then
For Each dl In se.DataLabels
If dl.ShowLegendKey = True Then
bDatalabelWithLegend = True
Exit For
End If
Next dl
Else
Dim pt As Point
For Each pt In se.Points
If pt.HasDataLabel Then
If pt.DataLabel.ShowLegendKey Then
bDatalabelWithLegend = True
Exit For
End If
End If
Next pt
End If
End If
End If
On Error GoTo HandleErrors
If bTrendline And bDatalabelWithLegend Then
Exit For
End If
Next se
If myChart.HasLegend Then
Dim legPos As Long
On Error Resume Next 'If legend moved accessing position will fail
legPos = myChart.Legend.Position
If (Err.Number <> 0) Or (legPos <> xlLegendPositionRight) Then
bLegendPosition = True
End If
On Error GoTo HandleErrors
End If
If IsPie(myChart) Then
bPiechartDirection = True
ElseIf myChart.ChartType <> xlDoughnut And myChart.ChartType <> xlBubble3DEffect Then
If myChart.HasAxis(xlValue, xlPrimary) Then
With myChart.Axes(xlValue, xlPrimary)
If .MajorUnitIsAuto And .MaximumScaleIsAuto And .MinimumScaleIsAuto And .MinorUnitIsAuto Then
bAxisInterval = True
End If
End With
End If
End If
On Error Resume Next 'If title has mixed font size accessing Font.Size will fail - Title mixed font issue
If myChart.HasTitle Then
fsize = myChart.chartTitle.Font.Size
If Err.Number = FontError Then
bTitleFont = True
End If
End If
On Error GoTo HandleErrors
If bUnsupportedType Or bTrendline Or bDatalabelWithLegend Or bLegendPosition Or bTitleFont Or bPiechartDirection Or bAxisInterval Then
FormatissueMinor = True
End If
FinalExit:
Set se = Nothing
Set dl = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Private Function SeriesIssue(myChart As Chart, bSeriesChartTypeChanged As Boolean, bDatasourceNotLinkedtoCell As Boolean, bDatasourceOnDifferentSheet As Boolean, bCategoryandValue As Boolean, bCLabelMorethanOneCell As Boolean, bOneColumnRow As Boolean) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SeriesIssue"
SeriesIssue = False
Dim Num As Integer
Dim I As Integer
Dim i2 As Integer
Dim formula As String
Dim p1 As Integer, p2 As Integer
Dim b1 As Integer, b2 As Integer
Dim comma1 As Integer, comma2 As Integer
Dim starty As Integer
Dim ctype As Integer
Dim temp As Integer
Dim myarray() As String
Dim Values(3), sh
Dim chartseries As Series
Dim b As Boolean
Dim bmorecolumns As Boolean
Dim c As Boolean
bmorecolumns = False
Num = myChart.SeriesCollection.count
If (Num = 0) Then Exit Function
ctype = myChart.SeriesCollection(1).ChartType
I = 0
sh = ""
ReDim Preserve myarray(Num, 3)
If IsPie(myChart) And Num > 1 Then 'if pie chart has more than one series,set series number to 1
bmorecolumns = True
Num = 1
End If
For Each chartseries In myChart.SeriesCollection
On Error Resume Next
formula = chartseries.formula
If Err.Number <> 0 Then
GoTo FinalExit
End If
If Not bSeriesChartTypeChanged Then 'check if the chart type changed
temp = chartseries.ChartType
If temp <> ctype Then
bSeriesChartTypeChanged = True
End If
End If
'get each part of the formula, if it is a single range, set the value to the array
p1 = InStr(1, formula, "(")
comma1 = InStr(1, formula, ",")
Values(0) = Mid(formula, p1 + 1, comma1 - p1 - 1)
If Mid(formula, comma1 + 1, 1) = "(" Then
' Multiple ranges
bDatasourceNotLinkedtoCell = True
GoTo FinalExit
Else
If Mid(formula, comma1 + 1, 1) = "{" Then
' Literal Array
bDatasourceNotLinkedtoCell = True
GoTo FinalExit
Else
' A single range
comma2 = InStr(comma1 + 1, formula, ",")
Values(1) = Mid(formula, comma1 + 1, comma2 - comma1 - 1)
starty = comma2
End If
End If
If Mid(formula, starty + 1, 1) = "(" Then
' Multiple ranges
bDatasourceNotLinkedtoCell = True
GoTo FinalExit
Else
If Mid(formula, starty + 1, 1) = "{" Then
' Literal Array
bDatasourceNotLinkedtoCell = True
GoTo FinalExit
Else
' A single range
comma1 = starty
comma2 = InStr(comma1 + 1, formula, ",")
Values(2) = Mid(formula, comma1 + 1, comma2 - comma1 - 1)
End If
End If
If SheetCheck(sh, Values) Then 'check if data from different sheet
bDatasourceOnDifferentSheet = True
GoTo FinalExit
End If
For i2 = 0 To 2 'set data to myarray, if it is range, assign the range address, else null
If IsRange(Values(i2)) Then
myarray(I, i2) = Range(Values(i2)).Address
'ElseIf (Not IsRange(values(i2))) And values(i2) <> "" Then
' bDatasourceNotLinkedtoCell = True
' myarray(i, i2) = ""
Else
bDatasourceNotLinkedtoCell = True
myarray(I, i2) = ""
End If
Next i2
I = I + 1
If bmorecolumns Then 'if it is pie chart, exit
Exit For
End If
Next chartseries
c = DataCheck(myarray, Num, bCategoryandValue, bCLabelMorethanOneCell, bOneColumnRow) 'check data values and category of the chart
FinalExit:
If bSeriesChartTypeChanged Or bDatasourceNotLinkedtoCell Or bDatasourceOnDifferentSheet Or bCategoryandValue Or bCLabelMorethanOneCell Or bOneColumnRow Then
SeriesIssue = True
End If
Last:
Set chartseries = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume Last
End Function
Private Function DataCheck(myarray() As String, Num As Integer, bCategoryandValue As Boolean, bCLabelMorethanOneCell As Boolean, bOneColumnRow As Boolean)
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "DataCheck"
Dim s1() As String
Dim v1() As String
Dim v2() As String
Dim c1() As String
Dim c2() As String
Dim bs1isrange As Boolean
Dim bc1isrange As Boolean
Dim bc2isrange As Boolean
Dim j As Integer
Dim I As Integer
Dim btemp1 As Boolean
Dim btemp2 As Boolean
bs1isrange = True
bc1isrange = True
bc2isrange = True
If myarray(0, 1) = "" Then
bs1isrange = False
Else
s1 = SplitRange(myarray(0, 1))
If UBound(s1) < 4 Then
bOneColumnRow = True
GoTo FinalExit
End If
If (Asclong(s1(0)) <> Asclong(s1(2))) And (Asclong(s1(1)) <> Asclong(s1(3))) Then
bCLabelMorethanOneCell = True
GoTo FinalExit
End If
End If
If myarray(0, 0) = "" Then
ReDim c1(2)
bc1isrange = False
c1(0) = ""
c1(1) = ""
Else
If InStr(1, myarray(0, 0), ":") <> 0 Then
bCLabelMorethanOneCell = True
GoTo FinalExit
End If
c1 = SplitRange(myarray(0, 0))
End If
v1 = SplitRange(myarray(0, 2))
If bs1isrange Then
btemp1 = s1(0) = s1(2) And s1(1) = v1(1) And s1(3) = v1(3) And Asclong(v1(0)) >= Asclong(s1(0)) + 1 'category beside first column
btemp2 = s1(1) = s1(3) And s1(0) = v1(0) And s1(2) = v1(2) And Asclong(v1(1)) >= Asclong(s1(1)) + 1 'category beside first row
If (Not btemp1) And (Not btemp2) Then
bCategoryandValue = True
GoTo FinalExit
End If
End If
If bc1isrange Then
btemp1 = v1(0) = v1(2) And c1(0) = v1(0) And Asclong(c1(1)) <= Asclong(v1(1)) - 1 'data label beside row
btemp2 = v1(1) = v1(3) And c1(1) = v1(1) And Asclong(c1(0)) <= Asclong(v1(0)) - 1 'data label beside column
If (Not btemp1) And (Not btemp2) Then
bCategoryandValue = True
GoTo FinalExit
End If
End If
For I = 1 To Num - 1
If myarray(I, 0) = "" Then
ReDim c2(2)
c2(0) = ""
c2(1) = ""
bc2isrange = False
Else
If InStr(1, myarray(0, 1), ":") = 0 Then
bCLabelMorethanOneCell = True
GoTo FinalExit
End If
c2 = SplitRange(myarray(I, 0))
End If
v2 = SplitRange(myarray(I, 2))
If bc2isrange Then
btemp1 = v1(0) = v1(2) And c2(0) = v2(0) And Asclong(c2(1)) <= Asclong(v2(1)) - 1 'data label beside row
btemp2 = v2(1) = v2(3) And c2(1) = v2(1) And Asclong(c2(0)) <= Asclong(v2(0)) - 1 'data label beside column
If (Not btemp1) And (Not btemp2) Then
bCategoryandValue = True
GoTo FinalExit
'break
End If
End If
If bc1isrange And bc2isrange Then
'series data beside last series data in column and data label beside last series data label
btemp1 = v2(0) = v2(2) And Asclong(c2(0)) = Asclong(c1(0)) + 1 And c2(1) = c1(1) And Asclong(v2(0)) = Asclong(v1(0)) + 1 And v1(1) = v2(1) And v1(3) = v2(3)
'series data beside last series data in row and data label beside laast series data label
btemp2 = v2(1) = v2(3) And c1(0) = c2(0) And Asclong(c2(1)) = Asclong(c1(1)) + 1 And Asclong(v2(1)) = Asclong(v1(1)) + 1 And v1(0) = v2(0) And v1(2) = v2(2)
If (Not btemp1) And (Not btemp2) Then
bCategoryandValue = True
GoTo FinalExit
End If
ElseIf Not bc2isrange Then
btemp1 = v2(0) = v2(2) And Asclong(v2(0)) = Asclong(v1(0)) + 1 And v1(1) = v2(1) And v1(3) = v2(3) 'series data beside last series data in column
btemp2 = v2(1) = v2(3) And Asclong(v2(1)) = Asclong(v1(1)) + 1 And v1(0) = v2(0) And v1(2) = v2(2) 'series data beside last series data in row
If (Not btemp1) And (Not btemp2) Then
bCategoryandValue = True
GoTo FinalExit
End If
End If
For j = 0 To 1
c1(j) = c2(j)
Next j
For j = 0 To 3
v1(j) = v2(j)
Next j
bc1isrange = bc2isrange
bc2isrange = True
Next I
FinalExit:
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Function SplitRange(a As String) As String()
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SplitRange"
Dim c1 As Integer, c2 As Integer, c3 As Integer
Dim start As Integer
Dim l As Integer
Dim rearray() As String
start = 2
If a <> "" Then
l = InStr(1, a, ":")
If l = 0 Then
ReDim rearray(2)
c1 = InStr(start, a, "$")
rearray(0) = Mid(a, start, c1 - start)
rearray(1) = Mid(a, c1 + 1, Len(a) - c1)
Else
ReDim rearray(4)
c1 = InStr(start, a, "$")
rearray(0) = Mid(a, start, c1 - start)
c2 = InStr(c1 + 1, a, "$")
rearray(1) = Mid(a, c1 + 1, c2 - c1 - 2)
c3 = InStr(c2 + 1, a, "$")
rearray(2) = Mid(a, c2 + 1, c3 - c2 - 1)
rearray(3) = Mid(a, c3 + 1, Len(a) - c3)
End If
Else
ReDim rearray(4)
rearray(0) = ""
rearray(1) = ""
rearray(2) = ""
rearray(3) = ""
End If
SplitRange = rearray
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Function Asclong(s As String) As Integer
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "Asclong"
Asclong = 0
Dim l As Integer
Dim I As Integer
Dim m As String
l = Len(s)
For I = 1 To l
m = Mid(s, I, 1)
Asclong = Asclong + Asc(m)
Next I
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Function SheetCheck(sh As Variant, Values() As Variant) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "SheetCheck"
SheetCheck = False
Dim c1 As Integer
Dim I As Integer
Dim temp
For I = 0 To 2
If IsRange(Values(I)) Then
c1 = InStr(1, Values(I), "!")
If sh = "" Then
sh = Mid(Values(I), 1, c1 - 1)
temp = Mid(Values(I), 1, c1 - 1)
Else
temp = Mid(Values(I), 1, c1 - 1)
End If
If temp <> sh Then
SheetCheck = True
Exit Function
End If
End If
Next I
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Function IsRange(Ref) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "IsRange"
Dim x As Range
On Error Resume Next
Set x = Range(Ref)
If Err = 0 Then
IsRange = True
Else
IsRange = False
End If
FinalExit:
Set x = Nothing
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
Resume FinalExit
End Function
Private Function IsPie(myChart As Chart) As Boolean
On Error GoTo HandleErrors
Dim currentFunctionName As String
currentFunctionName = "IsPie"
Dim ctype As Integer
IsPie = False
ctype = myChart.ChartType
If (ctype = xlPie) Or _
(ctype = xlPieExploded) Or _
(ctype = xlPieOfPie) Or _
(ctype = xl3DPie) Or _
(ctype = xl3DPieExploded) Then
IsPie = True
End If
Exit Function
HandleErrors:
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": " & Err.Number & " " & Err.Description & " " & Err.Source
End Function
Private Function IsOldVersion(aFormat As XlFileFormat) As Boolean
Dim theResult As Boolean
Dim currentFunctionName As String
currentFunctionName = "IsOldVersion"
Select Case aFormat
Case xlExcel2, xlExcel2FarEast, xlExcel3, xlExcel4, xlExcel4Workbook, xlExcel5, xlExcel7
theResult = True
Case xlExcel9795, xlWorkbookNormal
theResult = False
Case Else
WriteDebug currentFunctionName & " : " & mAnalysis.name & ": The version of this spreadsheet is not recognised"
End Select
IsOldVersion = theResult
End Function
|