I connect to sage50 with VBA code and the application starts - no problem. But then the system aks to put in username and password. How do I subbmit this values by VBA code?
I connect sage50 like this:
Option Explicit
Sub StartSage50()
Dim MyAppID
' --- Start sage50
MyAppID = Shell("C:\Program Files (x86)\Sage\Sage50\Lohn\Sage50Lohn.exe", 1)
' -
End Sub
Not sure if Sage50 uses the same COM API Sage 300 uses, but if it does you'll want to add a reference to the
AccpacCOMAPI
type library.To connect to Sage, you need to create an
AccpacSession
object:Then you need to invoke its
Init
method:From there you can get the available organizations (Sage databases) like this:
And now you have an
organizations
2D array that contains the database ID in one column, and the description in another - which is perfect for populating a 2-column dropdown/combobox on a custom login form, if you want one. Otherwise you can just hard-code your credentials when youOpen
the session:And the last & final step is to open the
DbLink
:And from there, you're good to go!