Repository navigation
Expand file tree
/
Copy path_AddInAPI.bas
More file actions
113 lines (94 loc) · 3.98 KB
/
Copy path_AddInAPI.bas
File metadata and controls
113 lines (94 loc) · 3.98 KB
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
Attribute VB_Name = "_AddInAPI"
Option Compare Database
Option Explicit
'---------------------------------------------------------------------------------------
' Function: API
'---------------------------------------------------------------------------------------
'
' Open API Information Form
'
'---------------------------------------------------------------------------------------
Public Function API()
DoCmd.OpenForm "InfoFormAPI"
End Function
'---------------------------------------------------------------------------------------
' Function: RunVcsCheckDialog
'---------------------------------------------------------------------------------------
'
' Equal to RunVcsCheck(True, vbNullString, True)
'
'---------------------------------------------------------------------------------------
Public Function RunVcsCheckDialog() As Variant
RunVcsCheckDialog = RunVcsCheck(True, , True)
End Function
'---------------------------------------------------------------------------------------
' Function: RunVcsCheck
'---------------------------------------------------------------------------------------
'
' Compare lettercase from CurrentVbProject with saved (table/file) dictionary items
'
' Parameters:
' OpenDialogToFixLettercase - (Boolean) - Open dialog to fix lettercase
' DeclDictFilePath - (String) - Use alternative dictionary file path
' IncludeUsedMembers - (Boolean) - Also add used members to the dictionary (default: False)
'
' Returns:
' Boolean (True) ... if DiffCount = 0
' String ... if DiffCount > 0 => "Failed: <lettercase info>"
' String ... if dict file not exists => "Info: No dictionary data found. A new dictionary has been created."
'
'---------------------------------------------------------------------------------------
Public Function RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean = False, _
Optional ByVal DeclDictFilePath As String = vbNullString, _
Optional ByVal IncludeUsedMembers As Boolean = False) As Variant
Dim CheckMsg As String
Dim DiffCnt As Long
Dim UseTable As Boolean
Dim StoreDictData As Boolean
Dim IntialCnt As Long
Dim DeclDict As DeclarationDict
Set DeclDict = New DeclarationDict
If Len(DeclDictFilePath) = 0 Then
DeclDictFilePath = CurrentProject.Path & "\" & CurrentProject.Name & ".DeclarationDict.txt"
End If
If Not DeclDict.LoadFromFile(DeclDictFilePath) Then
ImportVBProject CurrentVbProject, DeclDict, IncludeUsedMembers
' ... log info: first export
DeclDict.ExportToFile DeclDictFilePath
RunVcsCheck = "Info: No dictionary data found. A new dictionary has been created."
Exit Function
End If
IntialCnt = DeclDict.Count
ImportVBProject CurrentVbProject, DeclDict, IncludeUsedMembers
DiffCnt = DeclDict.DiffCount
If DiffCnt = 0 Then
If DeclDict.Count <> IntialCnt Then
StoreDictData = True
End If
End If
If OpenDialogToFixLettercase Then
If DiffCnt > 0 Then
SetDeclarationDictTransferReference DeclDict
DoCmd.OpenForm "DeclarationDictApiDialog", , , , , acDialog
DiffCnt = DeclDict.DiffCount
If DiffCnt = 0 Then
StoreDictData = True
End If
End If
End If
If StoreDictData Then
DeclDict.ExportToFile DeclDictFilePath
End If
If DiffCnt > 0 Then
CheckMsg = DeclDict.DiffCount & " word" & IIf(DeclDict.DiffCount > 1, "s", vbNullString) & " with different letter case"
RunVcsCheck = "Failed: " & CheckMsg
Else
RunVcsCheck = True
End If
End Function
Private Sub ImportVBProject(ByVal VbProjectToImport As VBIDE.VBProject, ByVal DeclDict As DeclarationDict, _
Optional ByVal IncludeUsedMembers As Boolean = False)
With New CodemoduleDeclarationReader
.ImportVBProject VbProjectToImport, DeclDict, IncludeUsedMembers
End With
End Sub