@@ -5,25 +5,35 @@ const MsgBoxTitle = "Update ACLib-AccUnit-Loader"
55MsgBox "Before updating the add-in file, the add-in must not be loaded!" & chr( 13 ) & _
66 "For safety, close all Access instances." , , MsgBoxTitle & ": Hinweis"
77
8+ Dim CompletedMsg
9+ Dim AddInFileInstalled
10+
811Select Case MsgBox( "Should the add-in be used as ACCDE?" + chr( 13 ) & _
912 "(Add-In is compiled and copied to the Add-In directory.)" , 3 , MsgBoxTitle)
1013 case 6 ' vbYes
1114 if CreateMde(GetSourceFileFullName, GetDestFileFullName) = True then
12- MsgBox "Compiled file was created." , , MsgBoxTitle
15+ CompletedMsg = "Compiled file was created."
16+ AddInFileInstalled = True
1317 else
14- MsgBox "Error! Compiled file was not created." , , MsgBoxTitle
18+ CompletedMsg = "Error! Compiled file was not created."
1519 end if
1620 case 7 ' vbNo
1721 DeleteAddInFiles
1822 if CopyFileAndRundPrecompileProc(GetSourceFileFullName, GetDestFileFullName) Then
19- MsgBox "File was copied." , , MsgBoxTitle
23+ CompletedMsg = "File was copied."
24+ AddInFileInstalled = True
2025 else
21- MsgBox "Error! File was not copied." , , MsgBoxTitle
26+ CompletedMsg = "Error! File was not copied."
2227 end if
2328 case else
2429
2530End Select
2631
32+ if AddInFileInstalled = True then
33+ RegisterAddIn GetDestFileFullName()
34+ end if
35+
36+ MsgBox CompletedMsg, , MsgBoxTitle
2737
2838'##################################################
2939' Hilfsfunktionen:
@@ -143,3 +153,64 @@ Function RunPrecompileProcedure(AccessApp, SourceFilePath)
143153 RunPrecompileProcedure = True
144154
145155End Function
156+
157+ Function RegisterAddIn(AddInFile)
158+
159+ Dim AddInDb, AccessApp, rst, ItemValue
160+ Dim wsh
161+
162+ Set AccessApp = CreateObject( "Access.Application" )
163+ Set AddInDb = AccessApp.DBEngine.OpenDatabase(AddInFile)
164+
165+ set wsh = CreateObject( "WScript.Shell" )
166+ Set rst = AddInDb.OpenRecordset( "select Subkey, ValName, Type, Value from USysRegInfo where ValName > '' Order By ValName" , 8 ) 'dbOpenForwardOnly=8
167+ Do While Not rst.EOF
168+ ItemValue = rst.Fields( "Value" ).Value
169+ If Len(ItemValue) > 0 Then
170+ If InStr( 1 , ItemValue, "|ACCDIR" ) > 0 Then
171+ ItemValue = AddInDb.Name
172+ End If
173+ End If
174+ RegisterMenuAddInItem AccessApp, wsh, rst.Fields( "Subkey" ).Value, rst.Fields( "ValName" ).Value, rst.Fields( "Type" ).Value, ItemValue
175+ rst.MoveNext
176+ Loop
177+ rst.Close
178+
179+ AddInDb.Close
180+
181+
182+ End Function
183+
184+ Function RegisterMenuAddInItem(AccessApp, wsh, ByVal SubKey, ByVal ItemValName, ByVal RegType, ByVal ItemValue)
185+ Dim RegName
186+ RegName = GetRegistryPath(SubKey, AccessApp)
187+ With wsh
188+ If Len(ItemValName) > 0 Then
189+ RegName = RegName & "\" & ItemValName
190+ End If
191+ .RegWrite RegName, ItemValue, GetRegTypeString(RegType)
192+ End With
193+ End Function
194+
195+ Function GetRegTypeString( ByVal RegType)
196+ Select Case RegType
197+ Case 1
198+ GetRegTypeString = "REG_SZ"
199+ Case 4
200+ GetRegTypeString = "REG_DWORD"
201+ Case 0
202+ GetRegTypeString = vbNullString
203+ Case Else
204+ Err.Raise vbObjectError, "GetRegTypeString" , "RegType not supported"
205+ End Select
206+ End Function
207+
208+ Function GetRegistryPath(SubKey, AccessApp)
209+ GetRegistryPath = Replace(SubKey, "HKEY_CURRENT_ACCESS_PROFILE" , HkeyCurrentAccessProfileRegistryPath(AccessApp))
210+ End Function
211+
212+ Function HkeyCurrentAccessProfileRegistryPath(AccessApp)
213+ HkeyCurrentAccessProfileRegistryPath = "HKCU\SOFTWARE\Microsoft\Office\" & AccessApp.Version & "\Access"
214+ End Function
215+
216+
0 commit comments