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 IntegerPublic 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 LongPublic Declare Function aaApi_DmsDataBufferSelect Lib "dmscli.dll" (ByVal lDmsBufferType As Long) As LongPublic 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 = 0End Enum
Const AAMODULE_ALL As Long = 0Const 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 projectDatabufferEnd Sub
Mike, try putting the path to the ProjectWise bin folder in your system PATH variable. This has helped me with a similar issue in the past.
Thanks Dean.
I did get this working and meant to come back here and document it. Since I was having touble with VBA I ended up writing a C++ DLL to call ProjectWise and then called my DLL from ProjectWise. I had trouble with this running as well.
What fixed the DLL problem was I added $(PWBIN) to the MS_LIBRARY_PATH configuration variable via Workspace, Configuration.
After I made that change the VBA program ran the next time I tried it. It's possible some other change I made was the cure but I think it was the configuration variable change that allowed the VBA program to run.
This solution is very similar to yours only I change a MicroStation variable rather than a system settings.