Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to view word/excel/ppt files

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
In a grid there are various files displayed. They are PDF, JPG, Docx, XLSx, PPTx.

The idea is to display a small sample once you hover the mouse over the gridcell.
I know how to do with PDF and JPG but I wonder if there's an other approach for the office-application others than instanciating the base-application.

TIA
-Bart
 
There is no general solution to display a preview in your own app.

In regard of PDF there are some solutions for, some are using activex controls, some use the webbrowser control. So depending on what you use in that matter, you'd either move that to a more general solution or continue using specific solutions for each file type.

If IE has the settings for the mime types DOC(X), XLS(X), etc, you can use the webbrowser control apporoach, but there is no guarantee customers will have the same setup.

Before I dive into that, what are you using for PDF right now?

Bye, Olaf.
 
Olaf,

The client is having a bunch of loose different documents which should be ordered by project. i.e. which documents do belong to which project.
So in the grid the docs are shown ordered at projectnumber.

In answer to your Q : the pdf's will have different content which I don't know much about.

KR
-Bart
 
That wasn't my question.

What code are4 you using to display PDF, what object or activex control.

Bye, Olaf.
 
I want to know that, because handling other files should best be done in the same manner. If you're using something sepcific for PDF, find something more specific for all document types. If you're using webbrowser control, continue using that for the other types as well. For example.

So my answer would depend on how you work with PDFs.

Bye. Olaf.
 
Bart,

It looks like you are using either the Web Browser control or an Internet Explorer object to display the PDFs (they amount to much the same thing). That indicates that you have made a setting within the default PDF viewer to display PDFs within a browser window, rather than opening them in a separate viewer application. That in turn indicates that you have some control over the users' system settings, which means that you can configure the users' systems to also display other document types in the browser window.

If those assumptions are correct, then you can use the same Web Browser control or an Internet Explorer object to display the different document types.

Does this makes sense?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
I tried by opening e.g. an excel sheet from IE. Than indeed from there an excel was instanciated. But if I use this way for opening an excel sheet while hovering over a gridcell than same might be achieved by directly instanciating excel though? Or do I oversee some?
-Bart
 
As Mike said, the file types need to be registered with the browser.

Also you can't open an excel sheet in a browser, but an excel workbook, an xls or xlsx. As with PDFs, you need to specify a file name.
If you use the exactly same code and specify a xls,doc,xlsx,docx file, the same as with PDFs should happen.

Unless: These file types are not registered with the browser, then the browser just forwards the documents to the standard application, not embedded in it's browser window.

See here:
That always is the downside of using the web browser or web browser control solution: This won't work everywhere, on top of an office installation it also needs the browser configured to support these file types internally via these registry settings. You can't rely on this to work in any computer.

Bye, Olaf.
 
Olaf,
I have not been aware of these registry keys and will give it a try to see it meet smy wishes.
KR
-Bart
 
I also just found them by googling for problems of such files not showing in the browser but starting separate. I always knew there was some mime type mapping, but that is all right. MS changed IE behavior in favor of security(?) to not display office documents embedded in the browser, it seems. In the past doc and other office types automatically were embedded in the internet explorer, too, once you had office installed. Now you explicitly need to set some registry keys.

My IE11 still prompts me to open or save a docx or xlsx, but whn choosing "open", it opens in the browser.

If you have some money to spend, I'd rather suggest using a viewer control capable to view pics, pdfs and office documents. It'll give you a more defined behavior, maybe even without depending on an office installation, as the new open xml formats are available. For example
I know I also promoted usage of the web browser control as universal viewer, but it's not as easy anymore, as it was, to use it for that.

Bye, Olaf.
 
Bart,

I've just been looking at a project I worked on in 2009, where I had to display the contents of various file types, similar to what you are doing. The files in queestion were DOC, XLS, CSV, PDF and TXT.

I did the whole thing in a web browser control. I simply placed the control on a form, and called its Navigate2 method, passing the full file path and name. I also told the client to go to the Preferences window in their Acrobat PDF viewer, and to set "Display PDF in browser". I don't remember them having to make any other settings or configuration changes.

This worked well, and I am not aware of any problems. I'm not saying you will be able to do exactly the same thing, as you need to support some different file types, and I don't know if you have any different configuration settings. But it does suggest that the web browser control will be worth experimenting with, if nothing else.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top