<?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: Selecting object, changing color, using form in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147912#M21864</link>
    <description>&amp;gt; depending on your version...&lt;BR /&gt;
 &amp;gt; objects no longer have .Color property... it's .TrueColor&lt;BR /&gt;
&lt;BR /&gt;
Has it actually gone from '08?&lt;BR /&gt;
&lt;BR /&gt;
In '07 .color can still be used but it didn't list in intellisense.&lt;BR /&gt;
&lt;BR /&gt;
Dave F.</description>
    <pubDate>Sat, 05 Jan 2008 19:22:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-01-05T19:22:47Z</dc:date>
    <item>
      <title>Selecting object, changing color, using form</title>
      <link>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147910#M21862</link>
      <description>I am trying to write a VBA macro that, when I select a polyline, and then click a shortcut key (or cmd button on a form) will simply change the color of the polyline.&lt;BR /&gt;
&lt;BR /&gt;
When I say selected, I mean highlighted with the blue boxes. (gripped?)&lt;BR /&gt;
The following code does that, but it only works when I have the VBA editor open. When I close the editor and bind the macro to a keyboard shortcut, it doesnt work. &lt;BR /&gt;
&lt;BR /&gt;
I would really like some code that does this:&lt;BR /&gt;
Show form-&amp;gt;click button to start process-&amp;gt; hide form-&amp;gt;user selects a polyline-&amp;gt;color is changed-&amp;gt;Form reappears...or something along those lines.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Code so far:&lt;BR /&gt;
&lt;BR /&gt;
Sub change_color_sel()&lt;BR /&gt;
Dim pfSS As AcadSelectionSet&lt;BR /&gt;
Dim ssobject As AutoCAD.AcadObject&lt;BR /&gt;
&lt;BR /&gt;
'Dim ssobject As AcadEntity&lt;BR /&gt;
Set pfSS = ThisDrawing.PickfirstSelectionSet&lt;BR /&gt;
For Each ssobject In pfSS&lt;BR /&gt;
ssobject.color = 2&lt;BR /&gt;
ssobject.Update&lt;BR /&gt;
Next&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-----&lt;BR /&gt;
Thanks in advance</description>
      <pubDate>Thu, 03 Jan 2008 19:11:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147910#M21862</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-03T19:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting object, changing color, using form</title>
      <link>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147911#M21863</link>
      <description>In general, there's no reason a routine wouldn't work when bound to a &lt;BR /&gt;
shortcut if it works in ide&lt;BR /&gt;
&lt;BR /&gt;
however, the phrase "doesn't work" doesn't help us help you  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
you should trap all possible errors and include Debug.Print calls or log &lt;BR /&gt;
events to file etc throughout any prog to see what's taking place, and where &lt;BR /&gt;
something bombs, then get the Err.Description when it bombs so you know why &lt;BR /&gt;
it "doesn't work"&lt;BR /&gt;
&lt;BR /&gt;
sadly, ThisDrawing.PickfirstSelectionSet is extremely buggy...you always &lt;BR /&gt;
have to test the return&lt;BR /&gt;
&lt;BR /&gt;
even if you weren't using that method, you always "should" test a selection &lt;BR /&gt;
set(or any other object for that matter) before using it...&lt;BR /&gt;
if obj is Nothing then....problem&lt;BR /&gt;
if obj.Count = 0 then... problem&lt;BR /&gt;
else&lt;BR /&gt;
'ok to proceed&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
depending on your version...&lt;BR /&gt;
objects no longer have .Color property... it's .TrueColor&lt;BR /&gt;
&lt;BR /&gt;
I would really like some code that does this:&lt;BR /&gt;
Show form-&amp;gt;click button to start process-&amp;gt; hide form-&amp;gt;user selects a &lt;BR /&gt;
polyline-&amp;gt;color is changed-&amp;gt;Form reappears...or something along those lines.&lt;BR /&gt;
&lt;BR /&gt;
if you want to use a form, create a user form, put a command button on it &lt;BR /&gt;
(name it cmd1 for instance)&lt;BR /&gt;
&lt;BR /&gt;
Then in&lt;BR /&gt;
Sub Cmd1_Click ()&lt;BR /&gt;
    Me.Hide&lt;BR /&gt;
    change_color_sel&lt;BR /&gt;
    Me.Show&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
create a module to fire up the form&lt;BR /&gt;
Sub Main()&lt;BR /&gt;
dim f as MyUserForm&lt;BR /&gt;
Set f = New MyUserForm&lt;BR /&gt;
f.Show&lt;BR /&gt;
Set f = Nothing&lt;BR /&gt;
End sub&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
caveat to using a form in this way...&lt;BR /&gt;
you have to use vl-vbarun to call your macro to allow you to pick on screen &lt;BR /&gt;
while a userform is hidden&lt;BR /&gt;
;;; however, it will crash the macro if toolbar button is clicked&lt;BR /&gt;
;;; AND IT WILL CANCEL PICKFIRST SELECTION SET&lt;BR /&gt;
&lt;BR /&gt;
hth&lt;BR /&gt;
Mark&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub change_color_sel()&lt;BR /&gt;
On Error GoTo ErrCtl&lt;BR /&gt;
&lt;BR /&gt;
Dim pfSS As AcadSelectionSet&lt;BR /&gt;
'Dim ssobject As AcadObject&lt;BR /&gt;
&lt;BR /&gt;
'this is fine since a sel set can only contain entities...&lt;BR /&gt;
Dim ssobject As AcadEntity&lt;BR /&gt;
Set pfSS = ThisDrawing.PickfirstSelectionSet&lt;BR /&gt;
&lt;BR /&gt;
'&amp;gt;&amp;gt;&amp;gt;&amp;gt; test pfSS before using....&lt;BR /&gt;
&lt;BR /&gt;
For Each ssobject In pfSS&lt;BR /&gt;
ssobject.color = 2&lt;BR /&gt;
ssobject.Update&lt;BR /&gt;
Next&lt;BR /&gt;
&lt;BR /&gt;
Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrCtl:&lt;BR /&gt;
&lt;BR /&gt;
'tells user about error but msg  is volatile(gone after closing msg box)&lt;BR /&gt;
MsgBox "Error occurred " &amp;amp; Err.Description&lt;BR /&gt;
&lt;BR /&gt;
'msg less volatile but have to open ide to look in Immediate window&lt;BR /&gt;
Debug.Print "Error occurred " &amp;amp; Err.Description&lt;BR /&gt;
&lt;BR /&gt;
'non volatile...save to text file or whereever for permanent record&lt;BR /&gt;
LogError "Error occurred " &amp;amp; Err.Description&lt;BR /&gt;
&lt;BR /&gt;
Err.Clear&lt;BR /&gt;
On Error GoTo 0&lt;BR /&gt;
End Sub</description>
      <pubDate>Thu, 03 Jan 2008 22:04:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147911#M21863</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-03T22:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting object, changing color, using form</title>
      <link>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147912#M21864</link>
      <description>&amp;gt; depending on your version...&lt;BR /&gt;
 &amp;gt; objects no longer have .Color property... it's .TrueColor&lt;BR /&gt;
&lt;BR /&gt;
Has it actually gone from '08?&lt;BR /&gt;
&lt;BR /&gt;
In '07 .color can still be used but it didn't list in intellisense.&lt;BR /&gt;
&lt;BR /&gt;
Dave F.</description>
      <pubDate>Sat, 05 Jan 2008 19:22:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/selecting-object-changing-color-using-form/m-p/2147912#M21864</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-01-05T19:22:47Z</dc:date>
    </item>
  </channel>
</rss>

