既存コマンドの実行

      2017/12/09

'Developer Help > General reference > Names and IDs or Commands in ArcGIS Engine
'ArcGIS Desktop
'******************************************************************************
'ArcMapの「データの追加」コマンド
Dim pUID As New UID
'pUID.Value = "{E1F29C6B-4E6B-11D2-AE2C-080009EC732A}"  'CLSIDで指定
pUID.Value = "esriArcMapUI.AddDataCommand"              'ProgIDで指定
 
Dim pCommandBars As ICommandBars
Set pCommandBars = ThisDocument.CommandBars
 
Dim pCommandItem As ICommandItem
Set pCommandItem = pCommandBars.Find(pUID)
 
pCommandItem.Execute
 
'ArcGIS Engine
'******************************************************************************
'ToolbarControl内の「データの追加」コマンド
Dim pUID As New UID
'pUID.Value = "{B100C679-76C5-410D-BC8D-AE9E7882A80F}"  'CLSIDで指定
pUID.Value = "esriControls.ControlsAddDataCommand"      'ProgIDで指定
 
Dim pToolbarControl As IToolbarControl
Set pToolbarControl = CType(axToolbarControl1.Object, IToolbarControl)
 
Dim pToolbarItem As IToolbarItem
Set pToolbarItem = pToolbarControl.GetItem(pToolbarControl.Find(pUID))
 
Dim pCommand As ICommand
Set pCommand = pToolbarItem.Command
 
If TypeOf pCommand Is ITool Then
    'ツールの有効化
    Set pToolbarControl.CurrentTool = CType(pCommand, ITool)
Else
    'コマンドの実行
    pCommand.OnClick
End If

 - プログラミング, ArcGIS , ,