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);

Recommended Answers

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.

Jump to Post

All 2 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.