Released: Windows and Office Preview Handler Pack

(Note: I completely rewrote this post on 18th March 2010 to bring it all up to date.)

Back with the release of Windows Vista, Microsoft introduced the concept of preview handlers. These let you preview all different file types from within Windows Explorer. Even better, they are both extensible (so you can add more types) and they work in Office too.

To make them more developer friendly, I developed a set of preview handlers for file types commonly used by developers.

Download Now

The pack works with:

  • Windows Vista
  • Windows 7
  • Outlook 2007
  • Outlook 2010

The pack adds support for:

  • ActionScript (.as)
  • ASPX (.aspx)
  • C# (.cs)
  • CSS (.css)
  • Diff (.diff, .patch)
  • DOS (.bat, .cmd)
  • JavaScript (.js)
  • Ruby (.rb, .rhtml, .rjs) thanks to Ivan Porto Carrero
  • SQL (.sql)
  • VB (.vb)

The project is basically just a stitched together set of other people’s work – there wasn’t much left for me to do considering:

If you’re interested in contributing your own ideas or adding more file types, just over to the source repository on CodePlex.

Previewing a C# (.cs) file in Vista

Previewing as ASP.NET (.aspx) file in Vista

Previewing a TSQL (.sql) file in Vista

77 comments

  1. Hi Tatham.

    Do you actually use Vista on your dev machine? I really like the vista styple + the new features but I am hesitating to upgrade because I heard rumours about nasty bugs with VS and especially third party software that runs smoothly on XP.

    bye,
    Elmar

  2. The site looks great ! Thanks for all your help ( past, present and future !)

  3. Would it be possible to build a Visio previewer? We use it all the time and can’t preview files in Vista. It is really annoying.

  4. @Nelson:

    Wow – you mean they still make Visio? :p

    If you’ve got any ideas on how I can render a Visio document in Windows Forms, I should be able to add this support for you relatively easily.

  5. XP did make the preview the first image of the cbr(rar)and cbz(zip) format files used for comics. A very practical tool to easily explore your collection. This feature is not supported now in Vista letting only to artists in programming as you to do the job. Such a “visual” system as Vista could be more consistent with early steps yet conquered. Normal users missing that facility will wait for an experienced and kind programmer to complement again the lazy Bill’s programmers. However, in the interim, congratulations on your new preview handlers.

  6. It works great, but it has one small annoying problem. When, for example, I preview a file (a .sql file in this example), and then I edit it in notepad, I cannot save the file because there is still an open handle to it.

    Even after I click off of the file, the handle still remains. I have to close the explorer instance to get the handle to let go of the file.

    I figure this is just a part of the methods provided…but i thought i’d ask anyway.

  7. Very nice.

    I’d love to see some .as (actionscript) preview support, it’s pretty much ecmascript/javascript.

  8. I just recently downloaded and installed this utility and I’m having a problem. When I try to preview .sql files it says there is a problem with the T-SQL previewer. Are there any known issues with this previewer? I’ve even tried rebooting the computer but now success.

    Thanks!

    Erik

  9. Woohoo – we passed the 1000 download mark last fortnight and I didn’t even realise. I seriously didn’t even think people were using this …

  10. I am just looking for a previewer for .html files. I know Vista has one, but has anyone written one for Outlook on XP? Many of us would be grateful if you did.

  11. Same problem with the T-SQL preview handler as Erik above. The error in the preview pane reads:

    This file cannot be previewed because of an error with the following previewer:

    T-SQL Code Preview Handler

    To open this file in its own program, double-click it.

    FYI, I’m using Outlook 2007 on Windows XP Pro SP2.

    Tatham, can you look into this? Thanks.

  12. Like Steven Vallarian, I have come across the problem that makes a previewer less than useful. If I preview an Excel file, an instance of Excel.exe is opened that stays open. This prevent me from double clicking an Excel file because the excel.exe that is already running prevents me from getting at Personal.xlsb, so my macros are not available.

    The only way I can use Excel freely is to shut down Explorer after previewing, then open Excel, then do File, Open and navigate to the file. Hardly practical!

    Could you suggest a solution?

  13. I would love to be able to preview .MHT / .MHTML files

    This is the “Excel 2000″ output for some horrible reporting software we’ve been forced to use. It has other options, but this is on the only output we’ve found that we can even open. The Excel 2003 option simply doesn’t work, so we’re stuck with MHTML on dozens of daily reports. Drives me crazy!

  14. I found a registry hack to support xml based files by previewing them with the aspx previewer:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\.xml\shellex]

    [HKEY_CLASSES_ROOT\.xml\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
    @=”{c3da7028-8de0-11db-96b6-005056c00008}”

    Paste this into an empty .reg file. Support for other filetypes can be added by replacing the .xml in the key.

  15. It seems to lock my files so I’m unable to delete them after being previewed… :(

  16. Great product But I’ve found another free preview handler which offers additional features:
    - Supports XML (.xml, .xsl)
    - Supports PHP
    - Supports Perl
    - Supports more than 20 other file formats
    - Written in C++. Faster and lower memory usage.
    - Files are not blocked when viewed. E.g. they can be saved/edited/deleted.

    The preview handler is available at:
    http://www.smartftp.local/client/addons/sourcepreview.php

    Regards,
    Cyber

  17. Hello, Thanks for this article. based on my personal experience (I have tried it successfully) you can get more previews by integrating Vista Preview Pane with QuickView Plus (as IE plug in). (www.avantstar.com).
    unfortunately it’s a little expensive shareware with 30 days trial. But there’s always another “way”, you know what i mean.
    The vendor tells about it still doesnt fully support Vista, but the IE plug in will still be installed as well.
    It supports more than 400 file types included most of known documents, images, and even apps binaries. So superior in my opinion. You don’t need associated applications anymore, and mainly no need to create specific preview handler any more. same thing due to other IE viewer activex plug ins.
    1. Download and install QuickView Plus on Vista. Launch it, Configure your custom file for IE plug in by clicking View – Confifugure QuickView Plus – Applications – Internet Explorer (IE plug in). then add your custom files (e.g. .dwg, .psd, .dll etc with their correct content type (MIME)
    2. Download MSDN Preview Handler. Install it.
    3. Download Preview Handler Editor or Preview Handler Configure. Open it then Look for “MSDN Internet Explorer Preview Handler”. select and add your custom files
    4. Activate Vista /Outlook preview pane. Select your file. the preview appears perfectly now.
    That’s it. Hopefully works. To me, it always works so far.
    Thanx and regards-Amirz

  18. to Cyber.
    Thanks for the info about smartftp source preview handler, is great.
    I manage to edit “SourcePreviewHandler.dll” using ResHacker and change the ugly Courier New font to Consolas, now is perfect ;-)

  19. Like Manuel, I also added additional extensions for the XML-type files. My current list is: .asax, .ashx, .config, .csproj, .resx, .user, .vbproj, .xml, .xsd, .xslt

  20. On my machine, under XP with Office 2007 it will not work to preview in Outlook 2007 for files received as attachments to emails.

    Outlook notices that the file extension of the attachment matches and gives you a button to click to preview but when you click the button it says there is an error in the previewer and you will have to double-click to see it.

    Any ideas?

    Thanks.

  21. I have the same experience on Server 2003 (enterprise) with Outlook 2007 — preview hanlder is registered, but an exception of some kind prevents it from previewing the attached file. In my case, I’m most interested in SQL files, I trade them frequently and would benefit from the previewer. I am using SSMS 2005 and SSMS 2008 on the same machine.

    Is this a file permission or Office trust issue?

  22. Has the locking issue been taken care of yet? If not, is there any target date that a fix for the locking issue will be provided.

  23. Any chance you could post the code for this or put it up on github/googlecode? I’d be interested in contributing some patches/features.

  24. looks like there is a bug where the previewer doesn’t release the file lock correctly because I can no longer save a file after is has been opened in the preview pane. Anyone else seeing this?

  25. very nice!
    Only .csv file extension is missing (tried with Outlook 2010)
    Maybe you can add it?

  26. Hi there…

    I am Using Office 2010 and XP SP3…
    I am very keen to use this Preview handlers but dont know how to do it…

    I want to use since 6-7 Months when i was using office 2007…
    i want to preview HTM files in Preview pane but not able to do so…. only some Preview are available now like PDF preview but not the HTM one yet…

    help me to apply the preview handler in my computer…

    Thanks.

  27. I can’t get the wav preview to work correctly in Outlook 2007 on Vista. I can see the preview in the preview window and I can play it, but I get no sound through the headset. All other system sounds are coming through the deadset fine. Any ideas?

    1. Hey Tom

      I want to do this preview handling in my outlook add-in but am kinda new to programming. So it would be great if you can tell me something how to start building one.

  28. I am also using Office 2010 and XP SP3…
    I am eager to know how could I preview HTM files in outlook…

  29. Can this be added to and used in a home grown Explorer type program written in Microsoft Visual Studio 2008 C#??

Comments are closed.