Print Word Document in C# – MS Office on Windows 64 bit Operation System – Error when you try Open Word Document or Print Word Document inside C#

יום חמישי, מרץ 24, 2011

When you try Open Word Document or Print Word Document inside C# Application on Windows 64 Operation System, you receive COM Object Error. For Example: object wordFileName = "c:\\temp\\test.docx";object unknown = System.Reflection.Missing.Value; object missing = Type.Missing; object readOnly = false; ApplicationClass wordApplication = new Microsoft.Office.Interop.Word.ApplicationClass(); wordApplication.Visible = false; // you may receive exception in next line Document wordDoc = wordApplication.Documents.Open(ref wordFileName, ref unknown, ref readOnly, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown, ref unknown);wordApplication.Application.Visible = false; wordApplication.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize;object background = false; object printToFile = false;object printAllDocument...