ujjwalesri

"ZoomToLayer" not working...

Discussion created by ujjwalesri on May 12, 2011
Latest reply on May 17, 2011 by ujjwalesri
Hi,
I am trying to call ZoomToLayer from my custom code.

ESRI.ArcGIS.esriSystem.UID pUID = new ESRI.ArcGIS.esriSystem.UID();
ICommandItem CmdItem;

//pUID.Value = "{18DF94D9-0F8A-11D2-94B1-080009EEBECB}";
pUID.Value = "esriArcMapUI.LayerContextMenuItems";
pUID.SubType = 7;

CmdItem = IApplication.Document.CommandBars.Find(pUID, true, false);

CmdItem.Execute();


Upon investigation I found that CommandItem.Action is throwing COMException:

'CmdItem.Action' threw an exception of type 'System.Runtime.InteropServices.COMException - This method cannot be called on built in commands.


I am trying to use it as a command and not tool...hence I cannot understand the exception.

Any ideas why it's happening?

Outcomes