Link to home
Start Free TrialLog in
Avatar of keimpe
keimpe

asked on

Office (Excel) document preview in VB6 or Access?

When I open a directory on my computer and select an Excel document, I see a preview of that document on the right hand side.

Is there any way to mimic this behaviour in VB6 or on an Access form?

In other words: can I show an Excel preview or thumbnail on an Access or VB6 form?

Thank you!
SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keimpe
keimpe

ASKER

That's a devastatingly brilliant idea! I've tried it (I believe the correct syntax is YourWebBrowser.Navigate  "c:\temp\sample.xls") and it almost works: the spreadsheet is opened in a new window (in Excel 2010) instead of in the browser control:

User generated image
this is the code used:

    Set ListView1.SmallIcons = ImageList1
    Set ListView1.Icons = ImageList1
    Set ListView1.ColumnHeaderIcons = ImageList1
    
    ListView1.ListItems.Clear
    ListView1.ColumnHeaders.Clear
    ListView1.Left = 200
    ListView1.Visible = True
    ListView1.ColumnHeaders.Add , , "Document", 150
    ListView1.ColumnHeaders.Add , , "Rubriek", 150
    ListView1.ColumnHeaders.Add , , "Volgnummer", 150
    ListView1.HideColumnHeaders = False
    ListView1.ListItems.Add 1, "Key", "Text", "imgKey", "imgKey"
    ListView1.ListItems.Add(2) = "Check Item 2"
    ListView1.ListItems(2).Icon = 1
    ListView1.ListItems.Add(3) = "Check Item 3"
    ListView1.ListItems(3).Icon = "imgKey"
    WebBrowser1.Navigate "file://c:/temp/sample.xlsx"

Open in new window


Any idea why it won't show up in the browser control?
Avatar of keimpe

ASKER

It does work on another machine with Office 2007 installed, so I need to do a little more testing on another 2010 machine. Maybe my office installation has gone bonkers (again). I'll report back here a.s.a.p. (but probably not today).

A little bonus question maybe: do you (or does anyone here) think it's possible (and if so, how) to show the Print Preview of an Excel sheet in the webbrowser control?
There's also a Navigate2 method of the control - can't recall what the difference is, but you might try using that instead of Navigate.

I don't know about the preview, since I'm not sure exactly how Excel renders the preview. I would think that no, you could not do that, since the Preview would be rendered in the Windows printing subsystem - but I could be wrong.
Avatar of keimpe

ASKER

I've tried Navigate2 with the same result (in my flawed Office 2010 installation), and I guess you're right about the preview impossibility.
Avatar of keimpe

ASKER

It seems we're out of luck. Navigating to Office 2007 (and up) files, opens them in their own program by design. Here's a 2007 workaround

I've yet to find a 2010 workaround.

Any other ideas on how to preview Excel files without opening them?

I've read you can save a thumbnail when you choose Save As, which seems true:

User generated image
But where can I find the resulting thumbnail???
I'm not sure how the Windows system previews them without opening, so I can't help any with that.

You could try the new Attachment feature of 2010, but this would require you to store the file in the Attachment field. Even then I believe you'd be out of luck with the preview, since I believe clicking on the item in the Attachment viewer will just launch the file in the host application.

You could also use the OLE Object control (the "Unbound Object Control") and set the SourceDoc property as needed. This won't really preview the item, it will actually open the item and allow the user to edit it, but it may serve your purpose.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fine with me - just be careful with controls that are not designed specifically to work in the Access environment.
Avatar of keimpe

ASKER

LSMConsulting's webbrowser solution is easiest and best for viewing Excel files up to and sometimes including 2007. My ActiveX solution is the only way for viewing Excel 2010 files. If you use a webbrowser it always opens the Excel file in a new window.

@LSMConsulting: Are you OK with the fact that I split the solution and the points?