Greetings,
I am trying to let the user click on an "AcDbText" object and then use a hot key (Ctrl + E) to execute the following code:
****Start Code****
Sub EditPieceMark()
Dim SelectedItem As AcadText
Dim SelectionSet As AcadSelectionSet
Dim ReturnPnt As Variant
Dim PieceMarkRef As String
Set SelectionSet = ThisDrawing.PickfirstSelectionSet
If SelectionSet(0).ObjectName = "AcDbText" Then
Set SelectedItem = SelectionSet(0)
PieceMarkRef = Left(SelectedItem, InStr(1, SelectedItem, " "))
PieceMarkRef = Right(PieceMarkRef, Len(PieceMarkRef) - 1)
Else
MsgBox "You have selected the wrong type of item for this operation", vbExclamation + vbOKOnly, "Non-Text Item Selected"
Exit Sub
End If
FormIdentifier = "Edit"
Load frmAddBOMPart(PieceMarkRef)
frmAddBOMPart.Show
End Sub
****End Code****
My problem is that whenever the user presses the hot key, it seems to deselect the item on the drawing so that the AcadSelectionSet.Count is always zero. This throws the following error: "Invalid argument index in Item". This occurs when the if statement is executed. Any help would be greatly appreciated.
I am trying to let the user click on an "AcDbText" object and then use a hot key (Ctrl + E) to execute the following code:
****Start Code****
Sub EditPieceMark()
Dim SelectedItem As AcadText
Dim SelectionSet As AcadSelectionSet
Dim ReturnPnt As Variant
Dim PieceMarkRef As String
Set SelectionSet = ThisDrawing.PickfirstSelectionSet
If SelectionSet(0).ObjectName = "AcDbText" Then
Set SelectedItem = SelectionSet(0)
PieceMarkRef = Left(SelectedItem, InStr(1, SelectedItem, " "))
PieceMarkRef = Right(PieceMarkRef, Len(PieceMarkRef) - 1)
Else
MsgBox "You have selected the wrong type of item for this operation", vbExclamation + vbOKOnly, "Non-Text Item Selected"
Exit Sub
End If
FormIdentifier = "Edit"
Load frmAddBOMPart(PieceMarkRef)
frmAddBOMPart.Show
End Sub
****End Code****
My problem is that whenever the user presses the hot key, it seems to deselect the item on the drawing so that the AcadSelectionSet.Count is always zero. This throws the following error: "Invalid argument index in Item". This occurs when the if statement is executed. Any help would be greatly appreciated.