laptop and a wrench

不具合

A custom toolbar created using ICommandBars.Create() cannot be obtained by ICommandBars.Find() on a separate sub-procedure in order to add built-in commands.

最後に公開された状態: October 11, 2017 ArcGIS for Desktop
不具合 ID 番号 NIM063076
送信されましたNovember 24, 2010
最終更新日June 5, 2024
適用対象ArcGIS for Desktop
見つかったバージョン10.0
プログラム言語VBA
オペレーティング システムWindows OS
オペレーティング システムのバージョンXP
ステータスWill Not Be Addressed

参考情報

VBA is no longer supported. Please use .NET instead

対処法

Add built-in commands using the reference to ICommandBar returned by ICommandBars.Create() instead of ICommandBars.Find(). In other words, follow the sample code in the following link: http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriFramework/ICommandBar_Example.htm If there is a need to first create a custom toolbar (for example, in the OpenDocument event of the MxDocument) and add built-in commands to that custom toolbar at a later time in the same ArcMap session, in a different sub procedure or function, use a module-level or global-level variable to use the reference to the custom toolbar returned by the Create() method and so one does not need to depend on the failing Find() method. See sample in this document VBA module: '***** Declare a module-level variable with the Private keyword ************** '** Alternatively, declare a global-level variable with the Public keyword *** '** Both module-level variables declared in this module called ThisDocument*** '** and global-level variables declared anywhere in the Project are ********** '** accessible by any statement in this module ******************************* Private m_pNewBar As ICommandBar 'Public g_pNewBar As ICommandBar Sub CreateBar1st() Dim pCmdBars As ICommandBars Set pCmdBars = ThisDocument.CommandBars 'Dim pNewBar As ICommandBar > no longer needed; declared as module-level ' ** Since the toolbar below is created and referenced by a module-level * ' ** variable, it will persist throughout the ArcMap session because the * ' ** ThisDocument module is linked to the .mxd file. ********************* Set m_pNewBar = pCmdBars.Create("MyBar", esriCmdBarTypeToolbar) End Sub Public Sub AddCommands2nd() '*** This procedure will attempt to add built-in commands *** '*** to a custom toolbar created previously during the ****** '*** same runtime (ArcMap session) using the Create() method* '*** Run this as a macro after CreateBar1st() has run.******* m_pNewBar.Add ArcID.File_AddData m_pNewBar.Add ArcID.PanZoom_FullExtent End Sub Private Function MxDocument_OpenDocument() As Boolean Call CreateBar1st End Function

再現の手順

不具合 ID: NIM063076

ソフトウェア:

  • ArcGIS for Desktop

バグのステータスが変更されたときに通知を受け取る

Esri Support アプリのダウンロード

このトピックについてさらに調べる

ArcGIS エキスパートのサポートを受ける

テクニカル サポートへのお問い合わせ

Esri Support アプリのダウンロード

ダウンロード オプションに移動