Question

I'm trying to make an extension and I need to call two commands from code...

  • SolutionExplorer.SyncWithActiveDocument
  • The Collapse All command in the Solution Explorer.

I can't find anyway to call these functions.

Does anyone know how to do this?

Was it helpful?

Solution

Have you tried executing the commands via the DTE?

dte.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Activate(); 

// Sync with Active Document
dte.ExecuteCommand("SolutionExplorer.SyncWithActiveDocument");

// Collapse All
int cmdidSolutionExplorerCollapseAll = 29;
Guid guidCMDSETID_StandardCommandSet11 = new Guid("D63DB1F0-404E-4B21-9648-CA8D99245EC3");
dte.Commands.Raise(guidCMDSETID_StandardCommandSet11.ToString("B"), cmdidSolutionExplorerCollapseAll, null, null);

If you need to identify the ID's for any other commands, you can switch on VSIP logging: http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top