<?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: Setting app.CurrentTool on cmd button not possible?  or just an error? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296821#M7694</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Craig,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Youre using the wrong guid, 952C7CAC* is the sketch tool palette.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following post should help you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=150668" rel="nofollow" target="_blank"&gt;Code to programmatically activate sketch tool?&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Sep 2012 16:58:22 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2012-09-06T16:58:22Z</dc:date>
    <item>
      <title>Setting app.CurrentTool on cmd button not possible?  or just an error?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296819#M7692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good morning,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having an issue with trying to set the CurrentTool to be the sketch tool.&amp;nbsp; I don't see why it should be much different than the&amp;nbsp; VBA sample in the help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Dim pItem As ICommandItem &amp;nbsp;&amp;nbsp; Set pItem =&amp;nbsp; CommandBars.Find(arcid.Query_Identify)&amp;nbsp; '{B7FA188F-EBE3-11D0-87FE-080009EC732A} &amp;nbsp;&amp;nbsp; Set Application.CurrentTool = pItem&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My version (in VB6) has more going on, but I don't see anything that should be an issue...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Private Sub cmdDrawPoly_Click() &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim fso As New FileSystemObject, sFolder As String &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pAppRot As IAppROT, pDoc As IMxDocument, pWSF As IWorkspaceFactory, pFWS As IFeatureWorkspace &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFClass As IFeatureClass, pFLayer As IFeatureLayer2, pLayer As ILayer2, pCommItem As ICommandItem &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pEditTask As IEditTask, iTaskCount As Integer, pCommBars As ICommandBars, pMap As IMap &amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pUID As New UID, pEditor As IEditor2&amp;nbsp;&amp;nbsp; tbStatus.Text = "Setting up for you to draw polygons around your area of interest.&amp;nbsp; Please wait!" &amp;nbsp;&amp;nbsp;&amp;nbsp; ' snipped a bunch of flags and data checks &amp;nbsp;&amp;nbsp;&amp;nbsp; subMakeNewFClass sFolder, "Custom_AON_Select_Layer.shp" 'add new fclass to map if gp is not set to add it ' snipped 'Close ArcCatalog if it is open... ' snipped 'turn on editing ' snipped 'Change the editing task... ' snipped&amp;nbsp; 'works fine up to here...&amp;nbsp; if I comment out the end I'm left with an open edit session, and the right task and target, only the tool remains whatever tool was in use when cmdDrawPoly got clicked.&amp;nbsp;&amp;nbsp;&amp;nbsp; 'set current tool &amp;nbsp;&amp;nbsp;&amp;nbsp; Set pCommBars = g_App.Document.CommandBars &amp;nbsp;&amp;nbsp;&amp;nbsp; pUID = "{952C7CAC-29BC-11D3-9F37-00C04F6BC979}" &amp;nbsp;&amp;nbsp;&amp;nbsp; Set pCommItem = pCommBars.Find(pUID) 'MsgBox 1 &amp;nbsp;&amp;nbsp;&amp;nbsp; Set g_App.CurrentTool = pCommItem 'MsgBox 2 &amp;nbsp;&amp;nbsp;&amp;nbsp; g_App.RefreshWindow &amp;nbsp;&amp;nbsp;&amp;nbsp; cmdCreateSelectionLayer.Enabled = True &amp;nbsp;&amp;nbsp;&amp;nbsp; tbStatus.Text = "Begin drawing.&amp;nbsp; When you are done, click 'Create Selection Layer'!" &amp;nbsp;&amp;nbsp;&amp;nbsp; 'Note: cmdCreateSelectionLayer closes the edit session if the user chose this method to highlight their AOI End Sub&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This fails between msgbox 1 and 2 as an "invalid procedure call or argument".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any insight at all would be extremely well received.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Take care,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Craig&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 14:12:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296819#M7692</guid>
      <dc:creator>CraigGraham</dc:creator>
      <dc:date>2012-09-06T14:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Setting app.CurrentTool on cmd button not possible?  or just an error?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296820#M7693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try passing the GUID to UID::Value&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;pUID.Value = "{952C7CAC-29BC-11D3-9F37-00C04F6BC979}"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 14:36:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296820#M7693</guid>
      <dc:creator>JohnHauck</dc:creator>
      <dc:date>2012-09-06T14:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Setting app.CurrentTool on cmd button not possible?  or just an error?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296821#M7694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Craig,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Youre using the wrong guid, 952C7CAC* is the sketch tool palette.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following post should help you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=150668" rel="nofollow" target="_blank"&gt;Code to programmatically activate sketch tool?&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 16:58:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296821#M7694</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-09-06T16:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Setting app.CurrentTool on cmd button not possible?  or just an error?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296822#M7695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Craig,&lt;BR /&gt;Youre using the wrong guid, 952C7CAC* is the sketch tool palette.&lt;BR /&gt;&lt;BR /&gt;The following post should help you.&lt;BR /&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=993&amp;amp;t=150668" rel="nofollow noopener noreferrer" target="_blank"&gt;Code to programmatically activate sketch tool?&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Sean,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had actually looked at that post before I posted, and I was about to link it as something I tried but didn't work, but I copied the GUID that the first guy was using not the one in the solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What a week.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To be clear for future ref.&amp;nbsp; Here is what I ended up with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pCommBars = g_App.Document.CommandBars
&amp;nbsp;&amp;nbsp;&amp;nbsp; pUID.Value = "{B479F48A-199D-11D1-9646-0000F8037368}"
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pCommItem = pCommBars.Find(pUID)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set g_App.CurrentTool = pCommItem
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After testing it a couple of times it seems like it works with the GUID being set to pUID, and pUID.Value&amp;nbsp; It was certainly worth a couple of tests though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Craig&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:14:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/setting-app-currenttool-on-cmd-button-not-possible/m-p/296822#M7695</guid>
      <dc:creator>CraigGraham</dc:creator>
      <dc:date>2021-12-11T14:14:11Z</dc:date>
    </item>
  </channel>
</rss>

