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

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
 
G

Guest

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.
 
V

VP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top