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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.