It errors because there is no On error resume next or something like that.
RIGHT! Now a word about
On Error Resume NextGurus can chime in if you disagree, but this is the worst kind of error checking in my opinion. It does work, and it is better than nothing, but its the lazy way out. Someday, you will have a situation where you need to catch the error and deal with it, and if you use this all the time, it will pass through and you will have no chance to fix the problem.
Now why did the example use it you ask? Well, the people at Autodesk can in no way anticipate what you are going to do, and they know your going to copy and paste, so they put that in so when you run it for the first time, and your just learning VBA, it works. Your linetypes load, your happy, and you move on.
So what is a better way of catching the error? Use
Select Case.
example to follow.