run-time error '13'
run-time error '13'
(OP)
I'm getting a run-time error '13' when running through a For Each/Next loop. What is a run-time '13' error and how can I avoid it?
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
|
RE: run-time error '13'
If you could post the error description, and the offending code, it might be helpful.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: run-time error '13'
For i = 1 To 5
If i = 1 Then Name = "MESA2_UX1100"
If i = 2 Then Name = "MESA3_UX1400"
If i = 3 Then Name = "MESA4_UX1500"
If i = 4 Then Name = "MESA5_UX1600"
If i = 5 Then Name = "MESA6_UX1700"
varCodeValues(0) = Name
Call SelectAll
MsgBox Name & " = " & objSS.Count
For Each LineObj In ThisDrawing.ActiveSelectionSet
stPoint = LineObj.StartPoint
endPoint = LineObj.endPoint
Next
When the program crashes, it has the last NEXT highlighted and the error code and "Type mismatch". Even if I take out everything in the For Each loop, I still get the error. The message box shows that I have many lines in the selection set (it's AutoCAD VBA), but I can't get through the For Each loop.
RE: run-time error '13'
Although not necessary, I would also suggest that for code readability, you explicitly identify what the 'next' refers to.
CODE
...
For Each LineObj in ThisDrawing.ActiveSelectionSet
...
Next LineObj
Next i
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: run-time error '13'
Yes the LineObj is viable. I put the message box right in front of the For Each statement to determine how many LineObj's were in the selection set. There is nothing else but LineObj's on that layer, so I know the number in the selection set is the number of LineObj's.
RE: run-time error '13'
What type is ThisDrawing? How has it been dimensioned?
Additionally, but a long shot, how are stPoint and endPoint declared, and are they of the same type as the corresponding LineObj properties?
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: run-time error '13'
Dim endPoint As Variant
Dim LineObj As AcadLine
I didn't dimension ThisDrawing since it is the reference to the current document. I have used these objects many times before in this same program and they work. I have used the same For Each loops with the same objects and it works. That's why it's so confusing on this particular one. It works on another file so it must be something related to the file I'm trying to extract the data from.
RE: run-time error '13'
For example, it may be that the program is expecting a LineObj as defined in AutoCad 2005, but the document was created using AutoCad 2004 so the definition of the LineObj object is different. That could result in a type mismatch error.
This could be caused by an early binding to the LineObj type (dim LineObj as AcadLine) but a late binding (not dimensioned) to the ThisDrawing object resulting in two different AutoCad object definitions.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: run-time error '13'