Muhtemelen accApp.Quit eklemek gerekir:
accApp.CloseCurrentDatabase
accApp.Quit
Set accApp = Nothing
önce Seti accApp = uygulamayı kapatmadan hızlandırmak ve on line, bu kodu (Ortak alt FindWordInOtherModules) yürütülürken kapatmak için hiçbir şey accApp.Quit, daha sonra değil. Bilgisayarımda, accApp.Quit eklendiyse, bu tür bir Sub uygulamasının çalıştırılmasından birkaç saniye sonra fare hala aktif değil.
Fakat geçerli veritabanı "geçici başvuru oluşturarak kendisine 'bağlantılı olabilir çünkü başka veritabanını açmaya gerek yoktur: Bu, başka bir veritabanı dosyası açılırken daha hızlı sonra olmak görünüyor
Private Sub FindWordInOtherModules2()
Dim objComponent As VBComponent
...
...
Dim lEndColumn As Long
Dim ref As Reference
Dim RefName As String
Const FileName = "C:\Users\....mdb"
With Application 'instead of accApp
.References.AddFromFile FileName
'.References.Count because the new one is supposed be the last one (?)
RefName = .References(.References.Count).Name
Dim VBProj As VBProject
For Each VBProj In .VBE.VBProjects
If VBProj.FileName <> .CurrentDb.Name Then Exit For
Next
For Each objComponent In VBProj.VBComponents
'Debug.Print objComponent.Name
...
...
Next
Set objComponent = Nothing '?
Set VBProj = Nothing '?
Set ref = .References(RefName)
.References.Remove ref
Set ref = Nothing '??
End With
End Sub
ama VBA güncellenmiş edilemez. ... References.Remove ref
referansını kaldırır, ancak VBA klasörler hala sol panelde görülebilir ve tüm kod biraz rahatsız edici olanı, işler
Application.VBE.VBProjects.Remove VBProj
çalışmıyor
. bir şeyler gerekebilir Trust'ta "VBA proje nesne modeline güven erişim" seçeneğiyle Merkezi - Access'te bulunmayan Makro Ayarları. Ancak, veritabanını kapatıp açtıktan sonra proje görünmez.