odtable.getodrecords.init error

odtable.getodrecords.init error

mirwing76
Contributor Contributor
574 Views
1 Reply
Message 1 of 2

odtable.getodrecords.init error

mirwing76
Contributor
Contributor

Function HasAttachRecord(objValue As AcadEntity, tblName As String) As Boolean

Dim ODtbl As AutocadMAP.ODTable
Dim ODtbls As AutocadMAP.ODTables
Dim ODRcs As AutocadMAP.ODRecords
Dim intODtablesCount As Integer 
Dim intItem As Integer 
Dim boolVal As Boolean

 

intItem = 0

Set ODtbls = proj.ODTables
intODtablesCount = ODtbls.Count - 1 

For intItem = 0 To intODtablesCount
If ODtbls.Item(intItem).Name = tblName Then
Set ODtbl = aMap.Projects(ThisDrawing).ODTables.Item(intItem)
Exit For
End If
Next

Set ODRcs = ODtbl.GetODRecords


boolVal = ODRcs.Init(objValue, False, False)   ' This line error!! error measge "Run-time error '5':  Invalid procedure call or argument

 

'

'

'

'odTable  attatch / cad object  / yes

HasAttachRecord = true

 

'odTable  attatch / cad object  / no

HasAttachRecord = false

 

End Function

 

 

Help Me Please!!

0 Likes
575 Views
1 Reply
Reply (1)
Message 2 of 2

dohenry
Contributor
Contributor

Hi mirwing76

 

It has been a few years since I have done VBA.

 

I quickly compared your code to some I had previously can't see anything straight of, however I have pasted below a extract from my code which may point you in the right direction.

 

I seem to remember the following line of code is important and notice it is missing from your code. And the second line is slight different to yours.

 

Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")


Set ODrcs = amap.Projects.Item(ThisDrawing).ODTables.Item(Object_Data_Table).GetODRecords

 

 

'I had multiple objects so I used a selectionset  

 

For i = 0 To objss.Count - 1    'I based 


boolVal = ODrcs.Init(objss.Item(i), False, False)  

 

 

Hope this is a help.

 

Good Look.

 

0 Likes