none
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

    Question

  • Hi there i got this pice of code

    in infopath button code behind

    through the above erro on Document.open

    what is the wrong bit i am doing in here ?

    appriciate all your help

    thanks

     

    string FileName = @"\\sbsfs02\\shares\\IT\\Documents\\New Starters\\NewStartTemplate.DOC";

                object NewFileName=@"\\sbsfs02\\shares\\IT\\Documents\\New Starters\\NewFile.DOC";

                object a = new object();

                Object READONLY = false;

                File.Copy(FileName, NewFileName.ToString());

                Microsoft.Office.Interop.Word.Application App = new Microsoft.Office.Interop.Word.Application();

               

                Document doc = App.Documents.Open(ref NewFileName, ref a, ref READONLY, ref a, ref a, ref a, ref a, ref a, ref a, ref a, ref a, ref a, ref a, ref a, ref a, ref a);

    Monday, September 17, 2012 10:55 AM

Answers

  • Hi Rushdy,

    You can change your code like below.

    string FileName = @"\\sbsfs02\\shares\\IT\\Documents\\New Starters\\NewStartTemplate.DOC"; object NewFileName = @"\\sbsfs02\\shares\\IT\\Documents\\New Starters\\NewFile.DOC"; object missing = System.Reflection.Missing.Value; object a = new object(); Object READONLY = false; File.Copy(FileName, NewFileName.ToString()); Microsoft.Office.Interop.Word.Application App = new Microsoft.Office.Interop.Word.Application(); Document doc = App.Documents.Open(ref NewFileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); App.Visible = true;



    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us


    Tuesday, September 18, 2012 9:29 AM
    Moderator

All replies

  • may be similar to your issue :http://www.add-in-express.com/forum/read.php?FID=5&TID=5534

    regards

    joon

    Monday, September 17, 2012 11:07 AM
  • thanks joon but my one is differnt to this

    Monday, September 17, 2012 11:26 AM
  • Hi Rushdy,

    You can change your code like below.

    string FileName = @"\\sbsfs02\\shares\\IT\\Documents\\New Starters\\NewStartTemplate.DOC"; object NewFileName = @"\\sbsfs02\\shares\\IT\\Documents\\New Starters\\NewFile.DOC"; object missing = System.Reflection.Missing.Value; object a = new object(); Object READONLY = false; File.Copy(FileName, NewFileName.ToString()); Microsoft.Office.Interop.Word.Application App = new Microsoft.Office.Interop.Word.Application(); Document doc = App.Documents.Open(ref NewFileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); App.Visible = true;



    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us


    Tuesday, September 18, 2012 9:29 AM
    Moderator