How to run MS Office Word with .NET without add-ons?

I am using MS Office 2003 PIA to create an MS Word document from C #.

ApplicationClass officeApplication = new ApplicationClass();

Is it possible to indicate that I do not want any utility add-ins to be loaded using this method?

EDIT:

I know that this can be done using the command line, so I'm sure there should be a way to do this from the code:

"C:\Program Files\Microsoft Office\Office11\Winword.exe" /a  
+3
source share
2 answers

This code unloads AddIns

officeApplication.AddIns.Unload(false);

Edited: Vacation rentals When you need to mix the start of the process and the ability to use the office "application" interface, you will need the Marshal.GetActiveObject command .
Example:

        //startup without plugins
        System.Diagnostics.Process.Start(
            @"Winword.exe",
            @"/a");
        //give a time for startup
        Thread.Sleep(2000);
        //attach to office
        Application officeApplication = (Application)Marshal.GetActiveObject("Word.Application");
+4
source

try it

System.Diagnostics.Process.Start(
  @"C:\Program Files\Microsoft Office\Office11\Winword.exe", 
  @"/a");
+2

Source: https://habr.com/ru/post/1704162/


All Articles