Word does not show up when trying to open doc thro C#

  • Thread starter Thread starter VP
  • Start date Start date
V

VP

Hi,

I am trying to open an existing word document, the execution happens
with no error but Word does not come up and my document does not open.

This is the code I am using..

Microsoft.Office.Interop.Word.ApplicationClass WordApp = new
Microsoft.Office.Interop.Word.ApplicationClass();

object missingValue = System.Reflection.Missing.Value;
object fileName = "C:\\test.doc" ;
object isVisible = true;

WordApp.Visible = true;

Microsoft.Office.Interop.Word.Document aDoc =
WordApp.Documents.Open(ref fileName, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref isVisible, ref missingValue, ref missingValue,
ref missingValue, ref missingValue);

WordApp.Visible = true;
aDoc.Activate();

Can anyone help me with this ?

thanks
V
 
Copied the code into a button click event on a c# windows application and it
worked perfectly after adding a reference to the word interop.
 
Hi,

Thats really weird. It still doesnt work for me, and I am doing
exactly that, on a button click event on my C# application. The funny
part is that the document shows that it is open when I check the
windows explorer -- but Word doesnt open up and I dont see my
document.
What could possibly be wrong?

Thanks
V
 
Back
Top