R
Riccardo
I want to set some references of a library i use in a main project. The code
to set them is written inside that library, here it is:
-------------------------------
Private Sub Aggiorna_Percorso_Libreria(ByVal nome As String, ByVal percorso
As String)
On Error GoTo Errore
Dim i As Byte
For i = 1 To CodeProject.Application.References.Count
If CodeProject.Application.References(i).Name = nome Then
If CodeProject.Application.References(i).FullPath = percorso
Then Exit Sub
CodeProject.Application.References.Remove
CodeProject.Application.References(i)
Exit For
End If
If CodeProject.Application.References(i).Name = percorso Then
CodeProject.Application.References.Remove
CodeProject.Application.References(i)
End If
Next i
If VBA.Dir(percorso) = "" Then MsgBox "Libreria mancante al percorso: "
& percorso & VBA.Chr(10) & "L'applicazione verra' chiusa", vbCritical,
"Errore critico": DoCmd.Quit ' Notare il VBA.Chr(10) e Dir. Sfruttato nel
caso una libreria non sia collegata
CodeProject.Application.References.AddFromFile percorso
Exit Sub
Errore:
MsgBox "Errore durante la registrazione della libreria: " & percorso,
vbCritical, "Errore critico"
DoCmd.Quit
End Sub
---------------------
This code is tested and works properly if i run it directly from the
library. The problem is that if i call that sub from the program that uses
the library, the references are set in the program that called that sub, not
in the library.
Example:
References before sub call:
Main.accdb
- Vba
- dao
Library.accdb
- Vba
- dao
References after sub call:
Main.accdb
- vba
- dao
- new reference
Library.accdb
- vba
- dao
But the new reference should be in the Library.accdb reference list not in
the main.
I know it's a bit complicated but i hope you can help me anyway.
Thanks
to set them is written inside that library, here it is:
-------------------------------
Private Sub Aggiorna_Percorso_Libreria(ByVal nome As String, ByVal percorso
As String)
On Error GoTo Errore
Dim i As Byte
For i = 1 To CodeProject.Application.References.Count
If CodeProject.Application.References(i).Name = nome Then
If CodeProject.Application.References(i).FullPath = percorso
Then Exit Sub
CodeProject.Application.References.Remove
CodeProject.Application.References(i)
Exit For
End If
If CodeProject.Application.References(i).Name = percorso Then
CodeProject.Application.References.Remove
CodeProject.Application.References(i)
End If
Next i
If VBA.Dir(percorso) = "" Then MsgBox "Libreria mancante al percorso: "
& percorso & VBA.Chr(10) & "L'applicazione verra' chiusa", vbCritical,
"Errore critico": DoCmd.Quit ' Notare il VBA.Chr(10) e Dir. Sfruttato nel
caso una libreria non sia collegata
CodeProject.Application.References.AddFromFile percorso
Exit Sub
Errore:
MsgBox "Errore durante la registrazione della libreria: " & percorso,
vbCritical, "Errore critico"
DoCmd.Quit
End Sub
---------------------
This code is tested and works properly if i run it directly from the
library. The problem is that if i call that sub from the program that uses
the library, the references are set in the program that called that sub, not
in the library.
Example:
References before sub call:
Main.accdb
- Vba
- dao
Library.accdb
- Vba
- dao
References after sub call:
Main.accdb
- vba
- dao
- new reference
Library.accdb
- vba
- dao
But the new reference should be in the Library.accdb reference list not in
the main.
I know it's a bit complicated but i hope you can help me anyway.
Thanks