AnsweredAssumed Answered

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

Question asked by cgraham on Sep 6, 2012
Latest reply on Sep 6, 2012 by cgraham
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,