1) i have made
a reference to microsoft.Office.Interop.Word
2) included a
namespace has "include Word=microsoft.Office.Interop.Word" and given
Word as alias to the above namespace
3) Word.Application WordApp =
new Word.Application();
Word.Document WordDoc = null;
created an instance for Application and Document class
4) object
missing =System.Reflection.Missing.Value
5)WordDoc =
WordApp.Documents.Open(ref filename, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing);
here i given valid path for
the file to be opened. but still my WordDoc gives me null vaule. (i have
cross checked my filepath twice)
kindly help me where i'm going
wrong.
thanks in advance.
Loading
Amit ChoudharyPosted Mar 11, 2010, 3:03 AM
May be some times we missed things in code.. try below code i'm using this in my projects:
object oMissing = System.Reflection.Missing.Value;oWord.Visible = true;Add your WodDoc.Add() after this code for opening a word file.
Please mark as answer if it helps you.