Wannabe
Wannabe

Reputation: 596

C# Microsoft.Office.Interop Word Doc not opening on first try

I am using the following code to open a Word doc

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();

Document document = app.Documents.Open("MyDocFile.doc");

After the code runs, a MS Word process is started but I never see my document. If I run the code a second time, another process is started and this time I get prompted to open a read-only copy because it is already open. I choose read-only and the document opens. Can someone tell me what I am doing wrong and why the document does not open on the first run of the above code?

Upvotes: 1

Views: 790

Answers (1)

Lift
Lift

Reputation: 546

Are you opening it with word for a particular reason? If you just want to open and see the file you can do this:

System.Diagnostics.Process.Start("YourSavedFilePath");

Upvotes: 1

Related Questions