网站搜索

如何(以及为什么)从命令提示符启动 Microsoft Excel


您可以从命令提示符打开 Microsoft Excel,还可以向命令添加其他参数以执行诸如使用特定模板打开 Excel 或在安全模式下启动 Excel 以进行故障排除等操作。

目录 使用命令提示符启动 Excel Excel 命令行开关和参数

使用命令提示符启动 Excel

使用命令提示符启动 Excel 的方法有很多种,但如果您想以正常状态启动 Excel(即,与单击快捷方式时 Excel 启动的方式相同),则有两种不同的方法。

首先,有一个简单的方法。通过在 Windows 搜索栏中键入“cmd”并从搜索结果中单击命令提示符应用程序来打开命令提示符。

命令提示符将打开。要启动 Excel,请键入此命令并按 Enter:

start excel

Excel 应立即启动。

打开 Excel 的另一种方法是找到包含 excel.exe 文件的目录,在命令提示符中切换到该目录,然后运行一个简单的命令。

要找到 excel.exe 文件,您需要位于命令提示符的 Program Files 目录中。您可以使用 cd 命令更改目录。在命令提示符中键入此命令,然后按 Enter:

cd\"program files"

您现在位于 Program Files 目录中。接下来,您需要找出 excel.exe 文件所在的目录。为此,请运行以下命令:

dir excel.exe /s

将返回 excel.exe 文件的目录。

现在您知道 excel.exe 所在的目录,导航到该目录。因为我们已经在 Program Files 目录中,所以我们可以在下一个命令中省略它。在我们的示例中,我们将运行此命令:

cd Microsoft Office\root\Office16

现在您位于正确的目录中,剩下要做的就是在命令提示符中键入 excel,然后按 Enter 键。

Excel 现在将打开。但是,从命令提示符启动 Excel 的主要目的是让您可以控制它的打开方式,您可以通过附加命令可用的各种开关和参数来实现。

Excel 命令行开关和参数

这是官方 Microsoft Office 支持站点提供的命令开关列表。将这些添加到命令提示符中 start excel 命令的末尾。

Switch and Parameter Description

workbook path | file name

No switch is required.

Opens the target file.

Example:

start excel “c:\Example Folder\file_name1.xlsx”

or

start excel http://MySite/file_name1.xlsx

/r workbook path | file name

Opens the target workbook as read-only.

Example:

start excel /r “c:\Example Folder\file_name1.xlsx”

or

start excel /r http://MySite/file_name1.xlsx

/t workbook path | file name

You can also use /n instead of /t to achieve the same result.

Opens the target file as a template.

Example:

start excel /t “c:\Example Folder\file_name1.xlsx”

or

start excel /t http://MySite/file_name1.xlsx

/e or /embed Prevents the Excel startup screen from appearing and a new blank workbook from opening.
/s or /safemode Starts Excel in Safe Mode. This launches Excel without any additional add-ins, templates, or other customizations. It’s helpful when troubleshooting problems in Excel.
/m Creates a new workbook that contains a single XLM macro sheet.
/a progID Loads the Automation add-in specified by the progID of the add-in.

Example:

start excel /a MyProgId.MyProgID2.1

/x Starts a separate process of Excel.

使用这些命令,您可以通过多种不同方式打开 Excel。

Excel 不是唯一可以使用命令提示符打开的 Office 程序,您还可以使用它来启动 Microsoft Word 和 PowerPoint。这些命令可能因应用程序而异,因此请探索每个应用程序可用的选项。