2008 VBA nor work since 2012 installed

2008 VBA nor work since 2012 installed

Anonymous
Not applicable
832 Views
4 Replies
Message 1 of 5

2008 VBA nor work since 2012 installed

Anonymous
Not applicable

We are running Map 2008 on several projects using in house VBA routines.  We just installed Civil 3D 2012, on our mahcines to start the migration.  But now the VBA routines crash cad when accessing Map.  Anyone else seen this problem?  We have uninstalled 2012 with no luck to the problem.  Reinstalled 2008 no luck.  Help please.

0 Likes
833 Views
4 Replies
Replies (4)
Message 2 of 5

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

besides the >>>crossposting<<< what and how crashes your routine.

You wrote that you had access to Map ==> what function, a code-snippet would be great as we don't see your screen!

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 5

Anonymous
Not applicable

''Works fine''

Set amap = ThisDrawing.Application.GetInterfaceObject("AutocadMap.Application.5")
    'Create OD Table Definition
    Set ODfdfs = amap.Projects(ThisDrawing).MapUtil.NewODFieldDefs
    ' Add Column Headings and Defaults
    Set ODfdf = ODfdfs.Add("SF", "SF", "0", 0)
    Set ODfdf = ODfdfs.Add("FN", "FN", "0", 1)
    Set ODfdf = ODfdfs.Add("CODE", "CODE", "0", 2)
    Set ODfdf = ODfdfs.Add("ATT1", "ATT1", "0", 3)
    Set ODfdf = ODfdfs.Add("ATT2", "ATT2", "0", 4)
    Set ODfdf = ODfdfs.Add("ATT3", "ATT3", "0", 5)
    Set ODfdf = ODfdfs.Add("ATT4", "ATT4", "0", 6)
    Set ODfdf = ODfdfs.Add("ATT5", "ATT5", "0", 7)
    Set ODfdf = ODfdfs.Add("ATT6", "ATT6", "0", 8)
    Set ODfdf = ODfdfs.Add("ATT7", "ATT7", "0", 9)
    Set ODfdf = ODfdfs.Add("ATT8", "ATT8", "0", 10)
    Set ODfdf = ODfdfs.Add("ATT9", "ATT9", "0", 11)
    Set ODfdf = ODfdfs.Add("ATT10", "ATT10", "0", 12)
 

 

''Crashes Cad''

If amap.Projects(ThisDrawing).ODTables.Item("SurveyPoint") Is Nothing Then

''run code

else

''run different code

end if

 

As soon as it trys to run the If clause it crashes cad.  This code as been working for years, until we put 2012 C3D on.  if have run it on a drawing that has the OD table "SurveyPoint" in it also and it to crashes.

0 Likes
Message 4 of 5

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

this code also crashes Map3D 2011, not only 2012 (I tried both as 64bit).

Try this code to check if an ODTable exists (I checked it with Map3D 2012 x64):

Public Sub test()
  Dim amap As AutocadMAP.AcadMap
  Set amap = ThisDrawing.Application.GetInterfaceObject("AutocadMap.Application.5")
  If existsODTable(amap.Projects(ThisDrawing), "abc") Then
    ''run code
  Else
    ''run different code
  End If
End Sub


Private Function existsODTable(ByRef MapProj As AutocadMAP.Project, ByVal TableName As String) As Boolean
   Dim tRetVal As Boolean: tRetVal = False
   Dim tTableNameU As String: tTableNameU = UCase(TableName)
   On Error Resume Next
   
   If MapProj.ODTables.Count > 0 Then
      Dim tTable As AutocadMAP.ODTable
      For Each tTable In MapProj.ODTables
         If UCase(tTable.Name) = tTableNameU Then
            tRetVal = True
            Exit For
         End If
      Next
   End If
   
   On Error GoTo 0
   existsODTable = tRetVal
End Function

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks for the Reply.  That Helped.  Had to fix a couple of other items afterwards, but your sample did the trick.

0 Likes