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

OLE and Notepad 1

Status
Not open for further replies.

mitzis

Programmer
Feb 6, 2003
3
CA
does anyone now how can i get an ole preview pane to display the contents of a .txt file. Word works, xls works, ppt works etc but i can get .txt files to be displayed. it just displays the notepad icon within the ole pane?? thx
 
Notepad itself does not support OLE so it can't be used to display the object - problem is .txt files are associated with Notepad so it is a no go.

Process for determining OLE server for an extension is:

In registry look up extension in HKEY_CLASSES_ROOT - and take the "(Default)" string for the extension e.g on my machine
.doc is "Word.Document.8"
.xls is Excel.Sheet.8
.txt is "txtfile"
.htm is "htmlfile"

Now look up the above strings in HKEY_CLASSES_ROOT - so for .doc we now look up Word.Document.8 and if that key has a subkey called CLSID then the association does support OLE - and if there is also an "Insertable" subkey the OLE server supports being inserted as an object (which is needed to show actual contents of file rather than just file name/icon etc) - for Word.Document.8 and Excel.Sheet.8 this is fine so they are OK to insert in your preview.
"txtfile" has neither CLSID or Insertable subkeys so has no OLE support
"htmfile" has a CLSID but has no Insertable key so will just show as an Icon

Using this logic you can set you app to see if any chosen file could be displayed - for some common file types you may want to build in another preview method to deal with files if not supported - so steps are:

1. Get file extension
2. look it up in registry and follow through to see if you have CLSID and Insertable as above
3. If you do - fine set your OLE control to display it
4. If not then if e.g. .txt extension then show in ordinary text box, if .htm or .html maybe use ShellExecute API to launch in browser etc etc etc
 
absolutely thankyou for your reply. Ive just quickly developed a whole document management system using vb ole and launching applications docs are associated with simply by using vboleopen , scripting.filesystemobject, and oracle blob records and the .createlink method - vb rocks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top