DTE2.ExecuteCommand(String, String) 方法


执行指定的命令。Executes the specified command.

void ExecuteCommand(std::wstring const & CommandName, std::wstring const & CommandArgs = "");
public void ExecuteCommand (string CommandName, string CommandArgs = "");
abstract member ExecuteCommand : string * string -> unit
Public Sub ExecuteCommand (CommandName As String, Optional CommandArgs As String = "")



必需。Required. 要调用的命令的名称。The name of the command to invoke.


可选。Optional. 一个字符串,其中包含在 命令 窗口中调用命令时要提供的相同参数。A string containing the same arguments you would supply if you were invoking the command from the Command window.

如果提供了字符串,则该字符串将作为命令的第一个参数传递给命令行,然后经过分析形成命令的各种参数。If a string is supplied, it is passed to the command line as the command's first argument and is parsed to form the various arguments for the command. 这类似于 命令 窗口中调用命令的方式。This is similar to how commands are invoked in the Command window.




Sub ExecuteCommandExample()  
   ' Open the New File dialog box.  
   ExecuteCommand ("File.NewFile")  
End Sub  


ExecuteCommand运行 "工具" 菜单上 "选项" 对话框的 "环境" 面板的 "键盘" 部分中列出的命令或宏。ExecuteCommand runs commands or macros listed in the Keyboard section of the Environment panel of the Options dialog box on the Tools menu.

你还可以通过在命令行中、在 命令 窗口中运行命令或宏,或通过按下与它们关联的工具栏按钮或按键来调用命令或宏。You can also invoke commands or macros by running them from the command line, in the Command window, or by pressing toolbar buttons or keystrokes associated with them.

ExecuteCommand 无法执行环境中当前禁用的命令。ExecuteCommand cannot execute commands that are currently disabled in the environment. Build例如,在生成当前正在进行时,将不会执行方法。The Build method, for example, will not execute while a build is currently in progress.

ExecuteCommand 隐式暂停宏记录,以便执行命令不发出宏代码。ExecuteCommand implicitly pauses macro recording so that the executing command does not emit macro code. 这可以防止在记录和调用宏时发出两个代码。This prevents double code emission when recording and invoking macros as part of what you are recording.