Author Topic: VBA Function not working in AutoCAD 2013  (Read 3508 times)

0 Members and 1 Guest are viewing this topic.

Tyke

  • Guest
VBA Function not working in AutoCAD 2013
« on: February 22, 2013, 11:50:13 AM »
I have a VBA module and a function in it which basically just creates a group. The function works fine on all AutoCAD versions 2008 to 2012, but in AutoCAD 2013 it crashes with an error message "Run time error '-2147417856 (800 10 100)".

Here's the function:

Code: [Select]
Public Function CreateGroup(grpName As String) As AcadGroup
   
    Dim colGroups As AcadGroups
    Dim objGroup As AcadGroup
   
    Set colGroups = ThisDrawing.Groups
   
    On Error Resume Next
   
    Set objGroup = ThisDrawing.Groups.Item(grpName)
   
    ' create the group
    If Not objGroup Is Nothing Then
        objGroup.Delete
    End If
   
    Set objGroup = ThisDrawing.Groups.Add(grpName)
   
    ' check if it was created
    If objGroup Is Nothing Then
        MsgBox "Unable to Add '" & grpName & "'"
    End If

End Function

When I go into debug mode it stops on:

Code: [Select]
Set colGroups = ThisDrawing.Groups
I tested it on two computers with the same results on both. It would appear to be a problem with 2013.

Has anyone else encountered this problem?