How to login in a multi project surrounding via VBA?
Using login functions in multi project surroundings restricts the full functionality of the user administration.
We recommend not to change the passwords during the runtime (if you would like to do this please contact our support ().
In addition you can use a global project where you create you users. This ensures that all projects have the same users saved.
At first create an online variable where you add the variable username of the system driver (SYSDRV).
Please add the following code at thisproject in the I-project:
Now as soon as you log in the user in the I-project, in all sub project the same user will logged in
public WithEvents obOLV As OnlineVariable
Private Sub Project_Active()
Set obOLV = thisProject.OnlineVariables.CreateOnlineVariables("onlineVar")
obOLV.Add "Username" 'The Variable Username of the SYSDRV should be added
Private Sub obOLV_VariableChange(ByVal obVar As IVariable)
Dim vVal As Variant
Dim i As Integer
Dim strCurrentUsername As String
vVal = obVar.Value
If IsError(vVal) Then Exit Sub
strCurrentUsername = Projects.Item("I-project").Passwords.LoggedUsername
if strCurrentUsername = "SYSTEM" Then
For i = 0 To Projects.Count - 1
'In the I project the user is already logged in
'all projects except the I-project should log in
If Projects.Item(i) <> "I-Project" Then
If Projects.Item(i).Passwords.login(strCurrentUsername) = False Then 'if the project log in fails
MsgBox "System wasn't able to log in the user " & strCurrentUsername & _
" in the project " & Projects.Item(i).Name
Private Sub Project_Inactive()
Please note that this VBA sample must get altered before you can use it in your project!
This is a migrated post! Originally posted on 28.08.2007 by user sebastiank. Please be aware that information can be outdated.