Hi All,
I wish to load Word Application without addins for purpose of previewing a document. This will help in getting the Word Application up faster .
I am currently using the following code
public Word.Application GetWordInstanceWithoutAddins()
{
Word.Application objWordApp;
Process proc = new Process();
proc.StartInfo.FileName ="winword.exe";
proc.StartInfo.Arguments =
"/a";
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.Close();
int retries = 0;
while (true)
{
try
{
if (Process.GetProcessesByName("winword").GetLength(0) > 0)
{
objWordApp = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
break;
}
}
catch { System.Threading.Thread.Sleep(500); }
if (retries > 5)
{
objWordApp = new Microsoft.Office.Interop.Word.Application();
break;
}
retries++;
}
objWordApp.Visible = false;
objWordApp = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
return objWordApp;
}
Posting this query in case there is a more elegant method.
Thanks
Tomy