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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open word, pdf, excel, txt docs internal in program

Status
Not open for further replies.

flbos

Programmer
Sep 15, 2005
41
NL
For a certain application I've got to make a form with a product overview. The form shows product number, description, price etc.
However, in some cases a product als has a technical document. I need to view this document when it's present but it needs to be showed within the application, this means within the form!

These documents can be of many different types: word, pdf, excel, txt, ppt, jpg, bmp (and maybe even other types in the future).
My question now is how can I implement a procedure that's able to launch all the different types of documents and show them in a specific part of my existing form. What I in fact need is to integrate the program that opens the document in my existing application, very much alike opening these document types in a web browser.

Is there a way to let the operating system open a given file type with its default launching program and then integrate this program in the form?
Or should I think differently and maybe something else will be a better solution?

Thanks in advance!!
 
i would look into using the browser object on the form, i vagly remember seeing referance at the ms developers web site a whole section on integrating ms office into your applications, as for pdf and the rest the browser object should have a way to view. it seems to me it would be simpler to have an icon in your form that would "shell out" to open the various documents you have mentioned.


if it is to be it's up to me
 
Why don't you try the 'Microsoft Web Browser' component. Just add it to your tool bar (its in COM Components), and drag/drop to the form. Then use AxWebBrowser1.Navigate2("filename") to load the file.

I have just tried it myself, and it works...
 
Thanks for the reactions!

The microsoft web browser component is an excellent suggestion, it works exactly as it should! However there is still one small problem left. When, for example, a pdf file is viewed in the web browser object then the focus automatically changes to the pdf document. This is not good because the main form should catch all keys that are pressed. In fact we use a scanner for this application which simulates the keystrokes of the different chars of an article number. I use the keydown procedure of the form to catch the simulated key strokes, a procedure then runs that shows the article info.

But when a pdf file is viewed in the browser object then the focus is changing automatically to the pdf document so that the form no longer catches the key strokes, key preview is on! Would there be a way to still catch the key strokes, also when a document (any type) is viewed in the browser object?

I tried simply changing the focus to the form after the procedure that loads the document but this doesn't help..

Thanks!
 
Ok, if you have a TextBox or simular control on the form, use TextBox1.Focus(). You may need to use the Focus command in the Browsers page load event (can't remember the exact name).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top