Select to view content in your preferred language

Setting app.CurrentTool on cmd button not possible?  or just an error?

864
3
Jump to solution
09-06-2012 07:12 AM
CraigGraham
Occasional Contributor
Good morning,

I am having an issue with trying to set the CurrentTool to be the sketch tool.  I don't see why it should be much different than the  VBA sample in the help:

Dim pItem As ICommandItem    Set pItem =  CommandBars.Find(arcid.Query_Identify)  '{B7FA188F-EBE3-11D0-87FE-080009EC732A}    Set Application.CurrentTool = pItem


My version (in VB6) has more going on, but I don't see anything that should be an issue...
Private Sub cmdDrawPoly_Click()     Dim fso As New FileSystemObject, sFolder As String     Dim pAppRot As IAppROT, pDoc As IMxDocument, pWSF As IWorkspaceFactory, pFWS As IFeatureWorkspace     Dim pFClass As IFeatureClass, pFLayer As IFeatureLayer2, pLayer As ILayer2, pCommItem As ICommandItem     Dim pEditTask As IEditTask, iTaskCount As Integer, pCommBars As ICommandBars, pMap As IMap     Dim pUID As New UID, pEditor As IEditor2   tbStatus.Text = "Setting up for you to draw polygons around your area of interest.  Please wait!"     ' snipped a bunch of flags and data checks     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  'works fine up to here...  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.    'set current tool     Set pCommBars = g_App.Document.CommandBars     pUID = "{952C7CAC-29BC-11D3-9F37-00C04F6BC979}"     Set pCommItem = pCommBars.Find(pUID) 'MsgBox 1     Set g_App.CurrentTool = pCommItem 'MsgBox 2     g_App.RefreshWindow     cmdCreateSelectionLayer.Enabled = True     tbStatus.Text = "Begin drawing.  When you are done, click 'Create Selection Layer'!"     'Note: cmdCreateSelectionLayer closes the edit session if the user chose this method to highlight their AOI End Sub


This fails between msgbox 1 and 2 as an "invalid procedure call or argument".

Any insight at all would be extremely well received. 

Take care,
Craig
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Craig,
Youre using the wrong guid, 952C7CAC* is the sketch tool palette.

The following post should help you.
Code to programmatically activate sketch tool?

View solution in original post

0 Kudos
3 Replies
JohnHauck
Frequent Contributor
Try passing the GUID to UID::Value

pUID.Value = "{952C7CAC-29BC-11D3-9F37-00C04F6BC979}"
0 Kudos
by Anonymous User
Not applicable
Craig,
Youre using the wrong guid, 952C7CAC* is the sketch tool palette.

The following post should help you.
Code to programmatically activate sketch tool?
0 Kudos
CraigGraham
Occasional Contributor
Craig,
Youre using the wrong guid, 952C7CAC* is the sketch tool palette.

The following post should help you.
Code to programmatically activate sketch tool?


Thanks Sean,
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.

What a week. 

To be clear for future ref.  Here is what I ended up with:

    Set pCommBars = g_App.Document.CommandBars
    pUID.Value = "{B479F48A-199D-11D1-9646-0000F8037368}"
    Set pCommItem = pCommBars.Find(pUID)
    Set g_App.CurrentTool = pCommItem


After testing it a couple of times it seems like it works with the GUID being set to pUID, and pUID.Value  It was certainly worth a couple of tests though.

Thanks again all,
Craig
0 Kudos