<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Accessing the Civil Application and Document Objects in VBA in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/accessing-the-civil-application-and-document-objects-in-vba/m-p/9710512#M4257</link>
    <description>&lt;P&gt;Hi I figured it out. It was a problem with the References to the Civil Object libraries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had loaded my 2020 vba project into Civil3D 2021. While the references appeared to be fine, I unticked them and then loaded again and it worked.&amp;nbsp;I loaded the type libraries from the following directory on my pc and it worked fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 133&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 25 Aug 2020 12:55:31 GMT</pubDate>
    <dc:creator>stephen_mitchell</dc:creator>
    <dc:date>2020-08-25T12:55:31Z</dc:date>
    <item>
      <title>Accessing the Civil Application and Document Objects in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/accessing-the-civil-application-and-document-objects-in-vba/m-p/9710456#M4256</link>
      <description>&lt;P&gt;I have been using the following function in Civil3D 2020 to access the Civil Application Object and it works fine. It does not seem to work in Civil3D 2021?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get an error on the line&amp;nbsp;"Set g_oDocument = g_oCivilApp.ActiveDocument".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess it is something to do with being an AcadDocument and not an AeccDocument??? Any ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Public oAcadApp As AcadApplication
Public g_oCivilApp As AcadApplication
Public g_oDocument As AeccDocument
Public g_oDatabase As AeccDatabase


Function GetGlobalCivilObjects() As Boolean


Set oAcadApp = ThisDrawing.Application

If InStr(oAcadApp.Name, "Autodesk Civil 3D 2021") &amp;gt; 0 Then
Set g_oCivilApp = oAcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.13.3")
Else
MsgBox oAcadApp.Name &amp;amp; " is not supported by this program", vbCritical
GetGlobalCivilObjects = False
Exit Function
End If

If g_oCivilApp Is Nothing Then
GetGlobalCivilObjects = False
MsgBox "Error getting Civil3D Interface object", vbCritical, "GetGlobabCivilOjbects Error Message"
Exit Function
End If

Set g_oDocument = g_oCivilApp.ActiveDocument
Set g_oDatabase = g_oDocument.Database

GetGlobalCivilObjects = True

End Function&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 12:52:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/accessing-the-civil-application-and-document-objects-in-vba/m-p/9710456#M4256</guid>
      <dc:creator>stephen_mitchell</dc:creator>
      <dc:date>2020-08-26T12:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing the Civil Application and Document Objects in VBA</title>
      <link>https://forums.autodesk.com/t5/vba-forum/accessing-the-civil-application-and-document-objects-in-vba/m-p/9710512#M4257</link>
      <description>&lt;P&gt;Hi I figured it out. It was a problem with the References to the Civil Object libraries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had loaded my 2020 vba project into Civil3D 2021. While the references appeared to be fine, I unticked them and then loaded again and it worked.&amp;nbsp;I loaded the type libraries from the following directory on my pc and it worked fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C:\Program Files\Common Files\Autodesk Shared\Civil Engineering 133&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 12:55:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/accessing-the-civil-application-and-document-objects-in-vba/m-p/9710512#M4257</guid>
      <dc:creator>stephen_mitchell</dc:creator>
      <dc:date>2020-08-25T12:55:31Z</dc:date>
    </item>
  </channel>
</rss>

