V8i VBA - linking element to database

I'm working through the Learning Microstation VBA book.  I'm trying to connect an element to an external database so that I can assign information to it for reporting later.

The code in the text is this: 

Function CreateDatabaseLink(Mslink As Long, Entity As Long, DatabaseType As MsdDatabaseLinkage, IsInformation As Boolean, DisplayableAttributeType As Long) As DatabaseLink

End Function

Sub DatabaseLinkA()

Dim myElem As Element
Dim myLink As DatabaseLink
Set myElem = CommandState.GetLocatedElement(True)
Set myLink = CreateDatabaseLink(1, 1, msdDatabaseLinkageOleDb, True, 0)
myElem.AddDatabaseLink myLink
myElem.Rewrite

End Sub

with the exception that I have replaced "LinkType" in the book with "DatabaseType" - although the results are the same either way.  

In both cases, I have an element selected in the drawing, and when I run DatabaseLinkA(), Microstation crashes.

Any idea what's going on?

Layne

Parents Reply Children