News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • Can one start Excel 2019 from the command line (cmd.exe)?

    Posted on Matthew Comment on the AskWoody Lounge

    Home Forums AskWoody support Microsoft Office by version Office 2019 for PC Can one start Excel 2019 from the command line (cmd.exe)?

    Viewing 4 reply threads
    • Author
      Posts
      • #2015300 Reply
        Matthew
        AskWoody Plus

        Here’s the scenario between the old work PC and the new work PC.

        Old PC is 64-bit Windows 7 Enterprise, while new PC is 64-bit Windows 10 Education (1809).  Old PC has 32-bit Office Pro Plus 2013 (MSI) installed, while new PC has 64-bit Office Pro Plus 2019 (C2R) installed.

        With old PC, for years I have been able to start Excel from the command line (cmd.exe, not the Run box) within a batch file so as to automatically execute a macro to create a desired “pretty” XLS file (and save it as a PDF) from a CSV file.  Even if I didn’t want to do a batch file operation, I could use cmd.exe to go to the C:\Program Files (x86)\Microsoft Office\Office15 directory, type Excel, and it would start with a blank workbook.

        With new PC, using cmd.exe to go to the C:\Program FIles\Microsoft Office\root\Office16 directory, I know the excel.exe file is there, but when I type Excel, I immediately get a new command prompt in the cmd.exe window, and, about 20 seconds later, I get a pop-up box that says, “The application was unable to start correctly (0xc0000142).”

        Searching the Web on that error code has not been helpful, and the suggestions of reinstalling Office that I did find don’t make sense, given that I can start Excel in the normal “Windows” way, or from the Run box, and it seems to work fine.  (Office 2019 was pushed to new PC just earlier this week.)

        Is it impossible for me to start my Excel 2019 from cmd.exe, requiring me to use the normal “Windows” way or at least the Run box?  If so, is that due to an issue with Excel 2019, an issue with 64-bit Excel, an issue with Windows 10, or what?

        I’m probably the only person I know at my work site that would even think of starting Excel from cmd.exe, but being able to do what I described within a batch file saves time and I’d like to be able to continue to do it even with this new PC.

        Any info or suggestions would be appreciated.  Thanks.

      • #2015485 Reply
        zero2dash
        AskWoody Lounger

        I just tested this and was able to start Excel from both CMD and PowerShell on Win10 1809, Office 1902 [O365] C2R.

        My suggestion would be to do a repair install on Office on the new PC and see if that fixes the issue. I don’t normally start Excel from CLI, but it does appear that it does indeed & should work.

        1 user thanked author for this post.
      • #2015550 Reply
        Matthew
        AskWoody Plus

        Thanks for the repair reminder, zero2dash.  (I often forget about that feature.)  Office 2019 has 2 repair options, so I did the Quick Repair.  (The Online Repair would take longer and be more thorough.)  I was then able to launch excel.exe from the command line when in the directory on the C: drive.

        In my batch file, I normally do a SUBST command to create a drive (N:) that points to that C: directory, so that the batch line command will be shorter.  In doing that, I still get the same error.  Even when trying simply to start excel.exe from the N: prompt, I get the same error.

        So it appears at this point that there’s something goofy with the SUBST.  I don’t know what, but I can work around that by using the full C: directory in the batch line command.  I don’t need perfection; I just need the process to work.

        Thanks again.

      • #2015925 Reply
        Paul T
        AskWoody MVP

        As you have a batch file why do you need the command shorter?

        cheers, Paul

        • #2017403 Reply
          Matthew
          AskWoody Plus

          That’s a fair question.  I guess when I originally built the process a long time ago, I tested things command by command within a cmd.exe window, so it was nicer to have a short representation of the path, especially given that earlier versions of Windows did not allow you to paste via Ctrl-V into the cmd.exe window.

           

      • #2017595 Reply
        RetiredGeek
        AskWoody MVP

        Matthew,

        I just tried this from a Command Prompt:

        “C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE”

        Works, opens excel but with out a Workbook.

        This: “C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE” /t “G:\BEKDocs\Custom Office Templates\Book1.xltx”

        Will open it with a blank workbook template that you have created to do your fancy formatting.

        HTH 😎

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        • This reply was modified 9 months, 3 weeks ago by RetiredGeek.
        1 user thanked author for this post.
        • #2018625 Reply
          Matthew
          AskWoody Plus

          RG, thanks for the info.  For a long time I’ve been calling the desired template — located on my hard drive (not a network drive) — from the command line, but I’ve not explicitly used the /t switch.  When doing so just now, I don’t see any difference in what’s happening.

          What is happening now is that I’ve got things working again, but I have to intervene.  With old PC, I manually launched the batch file, because over time there were instances when launching it via scheduled task ran into some type of error, either in the Excel process or in concatenating pages together.  So I just decided that I’d manually launch it and watch it for any problems, but nearly always I just had to do that first double-click on the batch file and things would run through to completion.

          With new PC, Win 10 and/or Office 2019 seem to be much pickier about security, so after doing the double-click, when it gets to the Excel part, I get a message about “protected view” and have to click the [Enable Editing] box, then I get a message about “security warning” and have to click the [Enable Content] box before the macros will run.  I can fiddle with the Trust Center settings to get rid of one of those, but then the macros won’t run.  I tried a bunch of things earlier in the week and didn’t get anything better, so I’m leaving well enough alone.

          So, since I was previously willing to live with double-click and watching the batch file run, I can tolerate clicking 2 boxes along the way to get through the process.  It’s certainly easier than doing part of the work in batch, then opening Excel the normal “Windows” way to execute the macros (without encountering the 2 boxes), then doing the rest of the work in more batch.

          I certainly have a love/hate relationship with MicroSquish as they change things over time.

           

    Viewing 4 reply threads

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: Can one start Excel 2019 from the command line (cmd.exe)?

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.