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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.