tags:

views:

437

answers:

2

I'm using MS Office 2003 PIA to create a MS Word document from c#.

ApplicationClass officeApplication = new ApplicationClass();

Is there any way to specify that I don't want any office add-ins to be loaded using this method?

EDIT:

I know that one can do this via command line so I'm pretty sure there must be a way to do it from code:

"C:\Program Files\Microsoft Office\Office11\Winword.exe" /a
+2  A: 

Try this

System.Diagnostics.Process.Start(
  @"C:\Program Files\Microsoft Office\Office11\Winword.exe", 
  @"/a");
JaredPar
Thanks, but I specifically want to use the PIA as above.
Andrew Jackson
+4  A: 

This code unload the AddIns

officeApplication.AddIns.Unload(false);

Edited:

When you need to mix the process start and possibility to use the office "application" interface, you 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");
Avram
Is there a way to stop them loading in the first place? I'm trying to avoid the startup performance hit when customers have lots of add-ins. I need to start word quickly, do some processing and close it again.
Andrew Jackson
@Andrew ,see at my update.
Avram
Ah, Thank you. Thats what I am looking for!
Andrew Jackson