I am running a .exe that i pass an argument to, using Office.Interop v15. It works fine on the dev machine which is windows 7 with Office 2013. When i move to a VM that is running Windows XP and Office 2010, i get a run time error stating
System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
Is it because the interop v15 doesn't support a lower version of office?
Snippet where error occurs
doc = app.Documents.Open(fileToPrint) /happens here
doc.PrintOut(False)
doc.Close()
app.Quit()
Oddly enough it runs but just has a runtime error.
Try this.
Replace this code:
doc = app.Documents.Open(fileToPrint) /happens here
With this (in VB.NET)
Dim s_missing As Object = System.Reflection.Missing.Value
doc = app.Documents.Open (fileToPrint, s_missing, s_missing, s_missing, s_missing,s_missing, s_missing, s_missing, s_missing, s_missing, s_missing, s_missing, s_missing, s_missing, s_missing, s_missing)
Or with this (in C#)
static object s_missing = System.Reflection.Missing.Value;
doc = app.Documents.Open ( ref fileToPrint,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing,
ref s_missing );
User contributions licensed under CC BY-SA 3.0