Search code examples
command-lineargumentsms-office

How to find complete list of arguments to use WORD in CLI


I would like to know if it is possible to have all the arguments of the command / exe "winword".

In the official docs the are some examples:

https://support.microsoft.com/en-us/office/command-line-switches-for-microsoft-office-products-079164cd-4ef5-4178-b235-441737deb3a6

But there not all the commands, for example, there is "/mFilePrintDefault" or "/mFileExit"

The objective being to be able to print a pdf without user action.


Solution

  • The Macro Commands are going to vary from one version to the next and of course you can start with your own macro file or use an AutoMacro.

    The examples you give are 2 from part of the "Fixed Commands"

    There are three lists available but I have no idea which commands function in a specific version as a command line macro, you would need to try them out.

    ECMA-376 Office Open XML File Formats [ECMA-376], Fixed commands are here https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/37bf80f7-1d74-47f6-8721-aa077cadca4d

    ISO/IEC-29500 Office Open XML File Formats [ISO/IEC-29500:2012], Fixed commands are here https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/1ecf33cf-3601-45f0-89fb-0ab824739343

    And listed under Basic Types as https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-doc/e86aecb4-bb67-4de2-9b06-37771115f274

    A common example to show using more than one command(s) in sequence is

    "path to\winword.exe" "path and filename.docx" /q /n /mFilePrintDefault /mFileExit
    
    

    But your default printer needs to be a PDF one otherwise your macro needs to more complex