<?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: Newbie- Label Showing Active Layer in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673079#M33673</link>
    <description>To the OP:  Note that the solution to both of your problems in this drawing &lt;BR /&gt;
had to do with data types.  You're on the right track, don't get &lt;BR /&gt;
discouraged.  Just note that data types are extremely important, as you're &lt;BR /&gt;
seeing.  Once you get a fair understanding of the differences between &lt;BR /&gt;
objects (such as AcadLayer), doubles, integers, strings, etc., it will ar &lt;BR /&gt;
start flowing very nicely.&lt;BR /&gt;
&lt;BR /&gt;
..........and books like Mr. Sutphin's don't hurt, either.  I'd highly &lt;BR /&gt;
recommend anything he's written about VBA.&lt;BR /&gt;
&lt;BR /&gt;
"Joe Sutphin" &lt;JOESUTPHIN&gt; wrote in message &lt;BR /&gt;
news:5204189@discussion.autodesk.com...&lt;BR /&gt;
That won't work, use the code below:&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.ActiveLayer = ThisDrawing.Layers(ListBox1.Text)&lt;/JOESUTPHIN&gt;</description>
    <pubDate>Tue, 13 Jun 2006 14:08:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-06-13T14:08:00Z</dc:date>
    <item>
      <title>Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673075#M33669</link>
      <description>Why won't the following show the Active Layer? (Keep getting the debugger bugging me!)&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Userform_Activate()&lt;BR /&gt;
Label3.Caption = ThisDrawing.ActiveLayer&lt;BR /&gt;
End Sub</description>
      <pubDate>Tue, 13 Jun 2006 13:28:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673075#M33669</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T13:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673076#M33670</link>
      <description>Label3.Caption = ThisDrawing.ActiveLayer.Name&lt;BR /&gt;
&lt;BR /&gt;
&lt;NUMPTY&gt; wrote in message news:5204121@discussion.autodesk.com...&lt;BR /&gt;
Why won't the following show the Active Layer? (Keep getting the debugger &lt;BR /&gt;
bugging me!)&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Userform_Activate()&lt;BR /&gt;
Label3.Caption = ThisDrawing.ActiveLayer&lt;BR /&gt;
End Sub&lt;/NUMPTY&gt;</description>
      <pubDate>Tue, 13 Jun 2006 13:32:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673076#M33670</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T13:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673077#M33671</link>
      <description>Thank you Joe!&lt;BR /&gt;
&lt;BR /&gt;
I'm also trying to make a listbox showing all of the layers in CAD.  When the user selects the layer it becomes active.....&lt;BR /&gt;
&lt;BR /&gt;
Somebody advised the following but it doesn't seem to do anything:&lt;BR /&gt;
&lt;BR /&gt;
Private Sub ListBox1_Click()&lt;BR /&gt;
Dim layerObj As AcadLayer&lt;BR /&gt;
Set layerObj = ThisDrawing.Layers.Item(ListBox1.Text)&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
??</description>
      <pubDate>Tue, 13 Jun 2006 13:45:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673077#M33671</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T13:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673078#M33672</link>
      <description>That won't work, use the code below:&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.ActiveLayer = ThisDrawing.Layers(ListBox1.Text)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;NUMPTY&gt; wrote in message news:5204163@discussion.autodesk.com...&lt;BR /&gt;
Thank you Joe!&lt;BR /&gt;
&lt;BR /&gt;
I'm also trying to make a listbox showing all of the layers in CAD.  When &lt;BR /&gt;
the user selects the layer it becomes active.....&lt;BR /&gt;
&lt;BR /&gt;
Somebody advised the following but it doesn't seem to do anything:&lt;BR /&gt;
&lt;BR /&gt;
Private Sub ListBox1_Click()&lt;BR /&gt;
Dim layerObj As AcadLayer&lt;BR /&gt;
Set layerObj = ThisDrawing.Layers.Item(ListBox1.Text)&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
??&lt;/NUMPTY&gt;</description>
      <pubDate>Tue, 13 Jun 2006 13:53:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673078#M33672</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T13:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673079#M33673</link>
      <description>To the OP:  Note that the solution to both of your problems in this drawing &lt;BR /&gt;
had to do with data types.  You're on the right track, don't get &lt;BR /&gt;
discouraged.  Just note that data types are extremely important, as you're &lt;BR /&gt;
seeing.  Once you get a fair understanding of the differences between &lt;BR /&gt;
objects (such as AcadLayer), doubles, integers, strings, etc., it will ar &lt;BR /&gt;
start flowing very nicely.&lt;BR /&gt;
&lt;BR /&gt;
..........and books like Mr. Sutphin's don't hurt, either.  I'd highly &lt;BR /&gt;
recommend anything he's written about VBA.&lt;BR /&gt;
&lt;BR /&gt;
"Joe Sutphin" &lt;JOESUTPHIN&gt; wrote in message &lt;BR /&gt;
news:5204189@discussion.autodesk.com...&lt;BR /&gt;
That won't work, use the code below:&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.ActiveLayer = ThisDrawing.Layers(ListBox1.Text)&lt;/JOESUTPHIN&gt;</description>
      <pubDate>Tue, 13 Jun 2006 14:08:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673079#M33673</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T14:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673080#M33674</link>
      <description>I'm struggling a bit.  I am using a combination of Mr Sutphins book (very good BTW) and also my own trial and error.  &lt;BR /&gt;
The following seems to always return the MsgBox before I select the entity......sorry if I'm being annoying &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Private Sub CommandButton1_Click()&lt;BR /&gt;
'Allows user to pick entity that contains desired layer&lt;BR /&gt;
    Dim objDrawingObject As AcadEntity&lt;BR /&gt;
    Dim varEntityPickedPoint As Variant&lt;BR /&gt;
    &lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
    ThisDrawing.Utility.GetLayer objDrawingObject, varEntityPickedPoint, _&lt;BR /&gt;
                                            "Choose object to take layer from: "&lt;BR /&gt;
If objDrawingObject Is Nothing Then&lt;BR /&gt;
    MsgBox "You did not choose an object"&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.ActiveLayer = objDrawingObject&lt;BR /&gt;
    &lt;BR /&gt;
End Sub</description>
      <pubDate>Tue, 13 Jun 2006 14:59:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673080#M33674</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T14:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673081#M33675</link>
      <description>My last example must have slipped past you ...&lt;BR /&gt;
&lt;BR /&gt;
Private Sub CommandButton1_Click()&lt;BR /&gt;
'Allows user to pick entity that contains desired layer&lt;BR /&gt;
Dim objDrawingObject As AcadEntity&lt;BR /&gt;
Dim varEntityPickedPoint As Variant&lt;BR /&gt;
Dim NewLayer As AcadLayer&lt;BR /&gt;
&lt;BR /&gt;
    Me.Hide&lt;BR /&gt;
&lt;BR /&gt;
    'On Error Resume Next&lt;BR /&gt;
&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity objDrawingObject, varEntityPickedPoint, _&lt;BR /&gt;
                                            "Choose object to take layer &lt;BR /&gt;
from: "&lt;BR /&gt;
&lt;BR /&gt;
  If objDrawingObject Is Nothing Then&lt;BR /&gt;
    MsgBox "You did not choose an object"&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
  'change active layer to that of the object selected&lt;BR /&gt;
  Set NewLayer = ThisDrawing.Layers(objDrawingObject.Layer)&lt;BR /&gt;
  ThisDrawing.ActiveLayer = NewLayer&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Be carefully how you use On Error Resume Next&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;NUMPTY&gt; wrote in message news:5204322@discussion.autodesk.com...&lt;BR /&gt;
I'm struggling a bit.  I am using a combination of Mr Sutphins book (very &lt;BR /&gt;
good BTW) and also my own trial and error.&lt;BR /&gt;
The following seems to always return the MsgBox before I select the &lt;BR /&gt;
entity......sorry if I'm being annoying &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Private Sub CommandButton1_Click()&lt;BR /&gt;
'Allows user to pick entity that contains desired layer&lt;BR /&gt;
    Dim objDrawingObject As AcadEntity&lt;BR /&gt;
    Dim varEntityPickedPoint As Variant&lt;BR /&gt;
&lt;BR /&gt;
On Error Resume Next&lt;BR /&gt;
    ThisDrawing.Utility.GetLayer objDrawingObject, varEntityPickedPoint, _&lt;BR /&gt;
                                            "Choose object to take layer &lt;BR /&gt;
from: "&lt;BR /&gt;
If objDrawingObject Is Nothing Then&lt;BR /&gt;
    MsgBox "You did not choose an object"&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
ThisDrawing.ActiveLayer = objDrawingObject&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;/NUMPTY&gt;</description>
      <pubDate>Tue, 13 Jun 2006 15:17:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673081#M33675</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T15:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673082#M33676</link>
      <description>So close! It all works fine apart from when the user picks nothing and the MsgBox is shown, the program kicks the user out - instead of waiting for another entity to be picked......&lt;BR /&gt;
&lt;BR /&gt;
I promise that I'll read your chapter on "User Interaction and the Utility Object" before asking any more dumb questions after this one!</description>
      <pubDate>Tue, 13 Jun 2006 15:32:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673082#M33676</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T15:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673083#M33677</link>
      <description>Private Sub CommandButton1_Click()&lt;BR /&gt;
'Allows user to pick entity that contains desired layer&lt;BR /&gt;
Dim objDrawingObject As AcadEntity&lt;BR /&gt;
Dim varEntityPickedPoint As Variant&lt;BR /&gt;
Dim NewLayer As AcadLayer&lt;BR /&gt;
&lt;BR /&gt;
  Me.Hide&lt;BR /&gt;
&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
&lt;BR /&gt;
  Do&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity objDrawingObject, varEntityPickedPoint, _&lt;BR /&gt;
                                          "Choose object to take layer from: &lt;BR /&gt;
"&lt;BR /&gt;
    If Not objDrawingObject Is Nothing Then Err.Number = 0&lt;BR /&gt;
  Loop While Err &amp;lt;&amp;gt; 0&lt;BR /&gt;
&lt;BR /&gt;
  'change active layer to that of the object selected&lt;BR /&gt;
  Set NewLayer = ThisDrawing.Layers(objDrawingObject.Layer)&lt;BR /&gt;
  ThisDrawing.ActiveLayer = NewLayer&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;NUMPTY&gt; wrote in message news:5204377@discussion.autodesk.com...&lt;BR /&gt;
So close! It all works fine apart from when the user picks nothing and the &lt;BR /&gt;
MsgBox is shown, the program kicks the user out - instead of waiting for &lt;BR /&gt;
another entity to be picked......&lt;BR /&gt;
&lt;BR /&gt;
I promise that I'll read your chapter on "User Interaction and the Utility &lt;BR /&gt;
Object" before asking any more dumb questions after this one!&lt;/NUMPTY&gt;</description>
      <pubDate>Tue, 13 Jun 2006 15:47:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673083#M33677</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T15:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673084#M33678</link>
      <description>Excellent, you are as tolerant as a mother with a screaming infant. Consider me back under my rock whilst I do a little more learning.  Mind you, smoke me a kipper, as I will probably be back for breakfast! (blooming Inputbox - cancel is annoying me now but I'll save that delight for another time).&lt;BR /&gt;
&lt;BR /&gt;
Cheers.</description>
      <pubDate>Tue, 13 Jun 2006 15:56:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673084#M33678</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T15:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie- Label Showing Active Layer</title>
      <link>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673085#M33679</link>
      <description>The user interaction is actually one of the hardest things to get a handle &lt;BR /&gt;
on, IMO, particularly if you have any background in lisp.&lt;BR /&gt;
&lt;BR /&gt;
&lt;NUMPTY&gt; wrote in message news:5204377@discussion.autodesk.com...&lt;BR /&gt;
So close! It all works fine apart from when the user picks nothing and the &lt;BR /&gt;
MsgBox is shown, the program kicks the user out - instead of waiting for &lt;BR /&gt;
another entity to be picked......&lt;BR /&gt;
&lt;BR /&gt;
I promise that I'll read your chapter on "User Interaction and the Utility &lt;BR /&gt;
Object" before asking any more dumb questions after this one!&lt;/NUMPTY&gt;</description>
      <pubDate>Tue, 13 Jun 2006 16:05:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/newbie-label-showing-active-layer/m-p/1673085#M33679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-13T16:05:33Z</dc:date>
    </item>
  </channel>
</rss>

