Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) in c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gokulraj84
    New Member
    • Jul 2008
    • 1

    Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) in c#

    This is my Coding.
    [code=c#]
    Application newApp = new Application();

    // Response.

    // specifying the Source & Target file names
    // c:\\abc\\Source .doc;
    object Source = "F:\\Gokulraj\\ doc2.doc";
    object Target = "F:\\Gokulraj\\ Temp\\gokul.pdf ";


    object Unknown = Type.Missing;


    newApp.Document s.Open(ref Source, 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, ref Unknown,ref Unknown);


    object format ;
    string s = Microsoft.Offic e.Interop.Word. WdSaveFormat.wd FormatPDF.ToStr ing() ;
    format = (object)s;



    string s1="msoEncoding UTF8";
    object Encoding = (object)s1;

    newApp.ActiveDo cument.SaveAs(r ef Target, ref format,
    ref Unknown, ref Unknown, ref Unknown,
    ref Unknown, ref Unknown, ref Unknown,
    ref Unknown, ref Unknown, ref Unknown,
    ref Encoding, ref Unknown, ref Unknown,
    ref Unknown, ref Unknown);
    newApp.Quit(ref Unknown, ref Unknown, ref Unknown);
    [/code]

    I Tried this Coding the "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMIS MATCH)) in c#" is occured.

    This coding for to convert .doc to pdf without any third party tool. please help me very urgent....

    You give steps in brief manner
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Which line of code is triggering this error?

    Comment

    Working...