none
Documents.Open Returning Null RRS feed

  • Question

  • Hi everyone,

     

    I have some code that downloads a word document from a SharePoint site to a temp folder then opens up the Word document and makes changes to it.

    I've tested it and it works well on my Dev server but when I move the code to my Test environment, it returns a null. 

    I've checked the temp folder and the file is there.

    On my Dev server I'm running Office Standard 2010 and on my Test server I'm running Office Professional Plus 2010.

    Any ideas?

    Thursday, November 17, 2011 4:13 PM

Answers

  • Does msWord.Documents.Open(FilePath) opens the document in the UI? Is the document shown in the Protected View window? If so, you can find it in ProtectedViewWindows collection using ProtectedViewWindow.Document.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    • Marked as answer by Bruce Song Wednesday, December 7, 2011 11:10 AM
    Friday, November 18, 2011 9:06 AM

All replies

  • Hello,

    If you use 32-bit and 64-bit systems, check if you save the file and open it in the same folder.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Thursday, November 17, 2011 8:23 PM
  • Yes, I do

     

                   string FilePath = @"C:\temp\" + templateFile.Name.Split('.')[0] + fileGUID + "." + templateFile.Name.Split('.')[1];

                    buffer = templateFile.OpenBinary();

                    FileStream outStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write);

                    BinaryWriter fileWriter = new BinaryWriter(outStream);

     

                    fileWriter.Write(buffer);

                    fileWriter.Flush();

                    fileWriter.Close();

     

                    msWord.Visible = true;

                    msWordDoc = msWord.Documents.Open(FilePath);

    Thursday, November 17, 2011 8:30 PM
  • Does msWord.Documents.Open(FilePath) opens the document in the UI? Is the document shown in the Protected View window? If so, you can find it in ProtectedViewWindows collection using ProtectedViewWindow.Document.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    • Marked as answer by Bruce Song Wednesday, December 7, 2011 11:10 AM
    Friday, November 18, 2011 9:06 AM