Simple VBA app for accessing ProjectWise

I took a sample application from the Bentley Developer Network and stripped it down to a very simple test application to make sure I could connect to ProjectWise from VBA (code below).  There is no error checking going on here and I usually run it while debugging to validate the return values but someone may find this useful.  Note that you would have to change the user name and password information.  My test is setup for single sign-on.

I do have a question that I'm hoping someone can help me with.  If MicroStation SS3 gets launched by opening a file from ProjectWise Explorer then this test app runs fine.  If I just launch MicroStation and then try and run this app I get a "File not found: dmscli.dll" error message.  I thought maybe I needed to go to Tools, References and add dmscli.dll as a reference but I get a "Can't add a reference to the specified file" message.

I've looked thru the ProjectWise SDK documents and searched on-line for dmscli.dll and didn't find an answer.  Anyone know what I need to add or change to get it to find dmscli.dll everytime?

Thanks,

Mike

 

Option Explicit

Public Declare Function aaApi_Initialize Lib "dmscli.dll" (ByVal ulModule As Long) As Integer
Public Declare Function aaApi_Login Lib "dmscli.dll" (lDSType As Long, ByVal lptstrDataSource As String, ByVal lpctstrUsername As String, ByVal lpctstrPassword As String, ByVal lpctstrSchema As String) As Long
Public Declare Function aaApi_DmsDataBufferSelect Lib "dmscli.dll" (ByVal lDmsBufferType As Long) As Long
Public Declare Sub aaApi_DmsDataBufferFree Lib "dmscli.dll" (ByVal lDataBuffer As Long) ' $$$ CRITICAL that this is ByVal, if not it crashes MicroStation badly

Public Enum DataSourceTypes
    AAAPIDB_UNKNOWN = 0
End Enum

Const AAMODULE_ALL As Long = 0
Const AADMSBUFFER_PROJECT As Long = 18

Public Sub Login(lngDataSourceType As DataSourceTypes, strLoginDataSourceName As String, strLoginUserName As String, strLoginPassword As String)
    Dim lOK As Long

    lOK = aaApi_Login(lngDataSourceType, StrConv(strLoginDataSourceName, vbUnicode), StrConv(strLoginUserName, vbUnicode), StrConv(strLoginPassword, vbUnicode), "")
End Sub

Sub BDNzineCheckOutAndProcessFiles()
    Dim status  As Long
    Dim projectDatabuffer As Long
   
    ' Initialze ProjectWise connection
    status = aaApi_Initialize(AAMODULE_ALL)
       
    ' User Name and password blank for Windows single sign-on
    Login AAAPIDB_UNKNOWN, "projectwise:projectwise", "", "" ' <<< Must change user and password

    ' Load buffer with project info
    projectDatabuffer = aaApi_DmsDataBufferSelect(AADMSBUFFER_PROJECT)
   
    ' Free the buffer just allocated
    aaApi_DmsDataBufferFree projectDatabuffer
End Sub