954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Microsoft.Office.Interop.Word problem

Hi,

I'm getting the error at the doc.close in the last argument; type mismatch error

using object 11 com addin; for which the doc.close takes 3 arguments.

thx

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

            object file = textBox1.Text;
            object nullobj = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);                              

            doc.ActiveWindow.Selection.WholeStory();
            doc.ActiveWindow.Selection.Copy();
            IDataObject data = Clipboard.GetDataObject();

            richTextBox1.Text = data.GetData(DataFormats.Text).ToString();

            doc.Close(ref file, ref nullobj,ref nullobj);
gallian99
Junior Poster in Training
77 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

I didn't try your code but have a look on http://msdn.microsoft.com/en-us/library/af6z0wa2(VS.80).aspx and if it raises an error reply again.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

object readOnly=false;
wordApp .Documents.Close(ref readOnly, ref readOnly, ref missing);
doc= null;
wordApp .Quit(ref missing, ref missing, ref missing);

vineeta.agarwal
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You