<?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 vba code to vb.net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/vba-code-to-vb-net/m-p/6608891#M34279</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a learning exercise I am trying to convert a old vba program to vb.net. I am experienced in vb.net and AutoCAD but not&amp;nbsp;with programing Autocad. Hence the learning exercise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One issue I am having is converting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub cmdCreateLayerReport_Click()

'connect or instantiate microsoft word
Set mobjWord = CreateObject("Word.Application")

'make microsoft word visible
mobjWord.Visible = True

'create a new document in microsoft word
Set mobjDoc = mobjWord.Documents.Add

'set header and footer and page layout
With mobjDoc

    ' set page layout to landscape
    .PageSetup.Orientation = wdOrientLandscape
    
    'set header (drawing path and name)
    .Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Layer Report for:  " &amp;amp; Application.Documents(cboDrawingName.Value).Path &amp;amp; "\ " &amp;amp; Application.Documents(cboDrawingName.Value).Name
    
    'set footer (date created and total layer count)
    .Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Date Created: " &amp;amp; Date &amp;amp; vbTab &amp;amp; "Total # of Layers: " &amp;amp; Application.Documents(cboDrawingName.Value).Layers.Count
    
    'set page numbers
    .Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add wdAlignPageNumberRight

End With&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have converted everything up to the point of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Date Created: " &amp;amp; Date &amp;amp; vbTab &amp;amp; "Total # of Layers: " &amp;amp; &lt;FONT color="#ff0000"&gt;Application.Documents(cboDrawingName.Value).Layers.Count&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant figure out how to get the layer count to work. (I have adjusted the date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Please note that I am using Civil 3D 2016.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2016 17:58:18 GMT</pubDate>
    <dc:creator>David_Prontnicki</dc:creator>
    <dc:date>2016-10-07T17:58:18Z</dc:date>
    <item>
      <title>vba code to vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/vba-code-to-vb-net/m-p/6608891#M34279</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a learning exercise I am trying to convert a old vba program to vb.net. I am experienced in vb.net and AutoCAD but not&amp;nbsp;with programing Autocad. Hence the learning exercise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One issue I am having is converting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Private Sub cmdCreateLayerReport_Click()

'connect or instantiate microsoft word
Set mobjWord = CreateObject("Word.Application")

'make microsoft word visible
mobjWord.Visible = True

'create a new document in microsoft word
Set mobjDoc = mobjWord.Documents.Add

'set header and footer and page layout
With mobjDoc

    ' set page layout to landscape
    .PageSetup.Orientation = wdOrientLandscape
    
    'set header (drawing path and name)
    .Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "Layer Report for:  " &amp;amp; Application.Documents(cboDrawingName.Value).Path &amp;amp; "\ " &amp;amp; Application.Documents(cboDrawingName.Value).Name
    
    'set footer (date created and total layer count)
    .Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Date Created: " &amp;amp; Date &amp;amp; vbTab &amp;amp; "Total # of Layers: " &amp;amp; Application.Documents(cboDrawingName.Value).Layers.Count
    
    'set page numbers
    .Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers.Add wdAlignPageNumberRight

End With&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have converted everything up to the point of:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = "Date Created: " &amp;amp; Date &amp;amp; vbTab &amp;amp; "Total # of Layers: " &amp;amp; &lt;FONT color="#ff0000"&gt;Application.Documents(cboDrawingName.Value).Layers.Count&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant figure out how to get the layer count to work. (I have adjusted the date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Please note that I am using Civil 3D 2016.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 17:58:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vba-code-to-vb-net/m-p/6608891#M34279</guid>
      <dc:creator>David_Prontnicki</dc:creator>
      <dc:date>2016-10-07T17:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: vba code to vb.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/vba-code-to-vb-net/m-p/6609058#M34280</link>
      <description>I figured it out. I needed to add addition references and Used the code below:&lt;BR /&gt;&lt;BR /&gt;Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication&lt;BR /&gt;Dim acadDoc As Autodesk.AutoCAD.Interop.AcadDocument&lt;BR /&gt;Dim layercount As Integer&lt;BR /&gt;&lt;BR /&gt;AcadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;acadDoc = AcadApp.ActiveDocument&lt;BR /&gt;layercount = acadDoc.Layers.Count&lt;BR /&gt;&lt;BR /&gt;then modified it for the combobox</description>
      <pubDate>Fri, 07 Oct 2016 19:12:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/vba-code-to-vb-net/m-p/6609058#M34280</guid>
      <dc:creator>David_Prontnicki</dc:creator>
      <dc:date>2016-10-07T19:12:54Z</dc:date>
    </item>
  </channel>
</rss>

