I have the following Selection Set code. It works great on 3 out of 4 computers. 2 of these computers are identical, but one of these is the one that is giving me the problems. It is not finding the items (some of the time) giving a selection set error. When it does decide to start working, it does not have any problems. I can and have made some changes so that the user does not see a error pop up, it just does not work. This is not what I am trying to do. The items (blocks) are in the drawing and I want to select them.
Is there something that I need to set on that computer or something that I need to add to my code?
Thanks in advance,
Jason
(the CreateSelectionSet function is the one that is causing the error)
Code:
Public Function pullBlockValue(BlockName As String, Field As String) As String
Dim ssetObj As AcadSelectionSet
Dim I As Integer, ii As Integer
Dim myAttribute
' Create the selection set
Set ssetObj = pullBlocks(BlockName)
If ssetObj.Count > 0 Then
'the block is used in the drawing
myAttribute = ssetObj.Item(0).GetAttributes
For ii = 0 To UBound(myAttribute)
If myAttribute(ii).TagString = Field Or _
myAttribute(ii).TagString = UCase(Field) Then
pullBlockValue = myAttribute(ii).TextString
End If
Next
End If
End Function
Public Function pullBlocks(BlockName As String) As AcadSelectionSet
Dim I As Integer, ii As Integer
Dim myAttribute
Dim fType(0 To 1) As Integer
Dim fData(0 To 1) As Variant
Set pullBlocks = CreateSelectionSet()
If pullBlocks.Count = 0 Then Exit Function
fType(0) = 0
fData(0) = "INSERT"
fType(1) = 2
fData(1) = BlockName
pullBlocks.Clear
pullBlocks.Select acSelectionSetAll, , , fType, fData
If pullBlocks.Count = 0 And _
BlockName = "TITLE_BLOCK" Then
Set pullBlocks = pullBlocks("tblock_blk")
End If
End Function
Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet
Dim ss As AcadSelectionSet, I As Integer
On Error Resume Next
Set ss = ThisDrawing.SelectionSets(ssName)
If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
ss.Clear
Set CreateSelectionSet = ss
End Function