_DTE.ExecuteCommand(String, String) 方法

定义

执行指定的命令。

void ExecuteCommand(std::wstring const & CommandName, std::wstring const & CommandArgs = "");
[System.Runtime.InteropServices.DispId(222)]
public void ExecuteCommand (string CommandName, string CommandArgs = "");
[<System.Runtime.InteropServices.DispId(222)>]
abstract member ExecuteCommand : string * string -> unit
Public Sub ExecuteCommand (CommandName As String, Optional CommandArgs As String = "")

参数

CommandName
String

必需。 要调用的命令的名称。

CommandArgs
String

可选。 一个字符串,其中包含在 命令 窗口中调用命令时要提供的相同参数。

如果提供了字符串,则该字符串将作为命令的第一个参数传递给命令行,然后经过分析形成命令的各种参数。 这类似于 命令 窗口中调用命令的方式。

属性

示例

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

注解

ExecuteCommand运行 "工具" 菜单上 "选项" 对话框的 "键盘" 部分中列出的命令或宏。

你还可以通过在命令行中、在 命令 窗口中运行命令或宏,或通过按下与它们关联的工具栏按钮或按键来调用命令或宏。

ExecuteCommand 无法执行环境中当前禁用的命令。 Build例如,在生成当前正在进行时,将不会执行方法。

ExecuteCommand 隐式暂停宏记录,以便执行命令不发出宏代码。 这可以防止在记录和调用宏时发出两个代码。

适用于