none
Preview Handler does not open new .docx RRS feed

  • Question

  • I'm using IPreviewHandler::DoPreview (http://msdn.microsoft.com/es-ve/library/bb775313(v=VS.85).aspx) to preview files.

    In my app, I'm getting this exception "System.Runtime.InteropServices.COMException (0x86421008): Exception from HRESULT: 0x86421008" when I try to preview a new .docx file created in Explorer (In Explorer -> right-click -> new -> Microsoft Office Word Document).

    If I open the file in Word, then I modify and save it, it will be previewed correctly.

    Using other apps (Explorer, Office) happens the same. (I'm using Office 2007 and Win7)

    Is this an known error? Where can I see more details?

    Wednesday, April 20, 2011 4:07 PM

Answers

  • Hi Matias,

    Thanks for reporting this issue!   I can repro the problem on my side in Office 2007, also as you said, it can work fine with Office 2010.   So it seems to be an issue which is fixed in Office 2010. 

    One workaround would be to first check the file size by FileInfo.Length, if FileInfo.Length equals zero, we use other ways to display the preview since such file has no contents inside. 

    If you have any questions, please feel free to let me know.

    Good day!

    Thanks

     


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    • Marked as answer by Matias Pirra Wednesday, April 27, 2011 9:08 PM
    Tuesday, April 26, 2011 5:46 AM
    Moderator

All replies

  • Hi Matias,

    Does the problem occur in Office 2010 too?   Could you please show us more detailed codes about how you use IPreviewHandler::DoPreview method?   A Winform or VSTO?

    Thanks
    Pam

    Monday, April 25, 2011 7:30 AM
  • Hi Pam,

    I tested my app and Explorer with Office 2010 and this problem does not occur. It works fine!

    My app is WPF and here are some lines of code:

    private string _filePath;
    private object _comInstance = null;
    
    Type comType = Type.GetTypeFromCLSID(new Guid(handler.ID));
          try
          {
            _comInstance = Activator.CreateInstance(comType);
    
    
            ((IPreviewHandler)_comInstance).SetWindow(this.Handle, ref r);
            ((IPreviewHandler)_comInstance).DoPreview();
          }
          catch (Exception ex)
          {

    Thanks

    Matias

    • Edited by Matias Pirra Monday, April 25, 2011 5:16 PM again
    Monday, April 25, 2011 5:03 PM
  • Hi Matias,

    Thanks for reporting this issue!   I can repro the problem on my side in Office 2007, also as you said, it can work fine with Office 2010.   So it seems to be an issue which is fixed in Office 2010. 

    One workaround would be to first check the file size by FileInfo.Length, if FileInfo.Length equals zero, we use other ways to display the preview since such file has no contents inside. 

    If you have any questions, please feel free to let me know.

    Good day!

    Thanks

     


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    • Marked as answer by Matias Pirra Wednesday, April 27, 2011 9:08 PM
    Tuesday, April 26, 2011 5:46 AM
    Moderator
  • Hi Michael,

    Thanks for your answer

    Matias

    Wednesday, April 27, 2011 9:34 PM
  • You're welcome, Matias!

    Have a nice day!


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Thursday, April 28, 2011 1:11 AM
    Moderator
  • Hello,

    I have a similar problem that involves TXT Previewer (all other are working great).

    My OS is Windows 7 and I am using Visual Studio 2010. It's a simple windows form that previews different file types. It works ok when built in x64, but not with x86 (app crashes on DoPreview).

     

     if (CurrentPreviewHandler is IPreviewHandler)
    {
        // bind the preview handler to the control's bounds and preview  the content
        Rectangle r = ClientRectangle;
        ((IPreviewHandler)CurrentPreviewHandler).SetWindow(Handle, ref r);
    
       ((IPreviewHandler)CurrentPreviewHandler).DoPreview();
    
       return true;
    }
    

    Thanks,

    Best regards

    Friday, July 8, 2011 1:39 PM