ironfelix717
Registered User.
- Local time
- Today, 06:05
- Joined
- Sep 20, 2019
- Messages
- 193
Greetings all,
This topic is a long shot and well beyond my skill at the current time-- but a long shot that's worth shooting, as I know how deep the knowledge and experience runs on this forum.
Preface:
I have a custom file manager form that has a "preview" image control... pretty standard feature. The problem with this is that it displays only image type files. The files i'm looking to preview in this form range from common formats (Image, Office, PDF, Text, etc) to more un-popular formats (which Windows recognizes in it's Explorer Preview Pane). I once read that PDFs can be displayed as a preview with a web browser control or something, but that solves only one format in the long list (even if that is true).
The ability to display file previews is a feature that is very valuable to this application and is something I've been trying to solve for a long time.
Work Arounds:
After scouring the web extensively for a VB solution on generating preview images, I found nothing. And usually when such scenario occurs, I simply outsource the task to Python where the libraries already exist, build a script, and call from VBA. Done deal.
So, I went that route. And ultimately ended up with a lousy solution. Writing code to handle each format to generate a preview on a case by case basis is tedious and at the end of the day, the result is a slow script that works for only a handful of supported formats. Not to mention, many of the libraries out there come at a cost. With the free versions, the generated preview has a nice watermark on the resultant image.... I even hired a freelancer developer to build me a script that was more improved and supported more formats, but it had some bugs and currently occupies my PC's recycle bin. This is still an option I am re-considering if I can't solve it myself.
Explorer Previews:
The most effective strategy that has the greatest functionality here is to ""simply"" grab the Window's Explorer preview pane image. The preview pane has the ability to display a preview for more formats than there are preview generating libraries for (that includes every language). I believe this is because the writers of the parent application of the file format in question ("non-native" formats, ex: 3D model formats) build their own preview generators internal to their application which is installed in Windows). Explorer just does the handshake between the Preview Pane and the underlying "parent" application to get the preview. (and probably searches cache first). I am struggling with my words, but you get the point... i think... Whether that theory is true or not, the fact remains that whatever Windows is actually doing under the hood to serve a preview image, no code library out there is going to match it's ability. They simply don't exist. It is dynamic and far better than writing a script that can generate previews for maybe only 10 formats at best... Therefore, this makes accessing Explorer's Preview pane images the proper solution.
Where To Go:
So... Easy enough....
My question can be concluded by asking for some direction on how to achieve this in VBA. First, do you know a solution that exists already? If not, I suspect i'll need to use the Win API, which I'm not really experienced in. If that is the case, can someone point me in the right direction for this- if this is even feasible.
Thanks for your time
--Regards
----------------------------------------------
EDIT- SUPPORTED LINKS:
docs.microsoft preview-handlers
thumbnail-for-any-file-in-windows
c-sharp-get-thumbnail-from-file-via-windows-api
This topic is a long shot and well beyond my skill at the current time-- but a long shot that's worth shooting, as I know how deep the knowledge and experience runs on this forum.
Preface:
I have a custom file manager form that has a "preview" image control... pretty standard feature. The problem with this is that it displays only image type files. The files i'm looking to preview in this form range from common formats (Image, Office, PDF, Text, etc) to more un-popular formats (which Windows recognizes in it's Explorer Preview Pane). I once read that PDFs can be displayed as a preview with a web browser control or something, but that solves only one format in the long list (even if that is true).
The ability to display file previews is a feature that is very valuable to this application and is something I've been trying to solve for a long time.
Work Arounds:
After scouring the web extensively for a VB solution on generating preview images, I found nothing. And usually when such scenario occurs, I simply outsource the task to Python where the libraries already exist, build a script, and call from VBA. Done deal.
So, I went that route. And ultimately ended up with a lousy solution. Writing code to handle each format to generate a preview on a case by case basis is tedious and at the end of the day, the result is a slow script that works for only a handful of supported formats. Not to mention, many of the libraries out there come at a cost. With the free versions, the generated preview has a nice watermark on the resultant image.... I even hired a freelancer developer to build me a script that was more improved and supported more formats, but it had some bugs and currently occupies my PC's recycle bin. This is still an option I am re-considering if I can't solve it myself.
Explorer Previews:
The most effective strategy that has the greatest functionality here is to ""simply"" grab the Window's Explorer preview pane image. The preview pane has the ability to display a preview for more formats than there are preview generating libraries for (that includes every language). I believe this is because the writers of the parent application of the file format in question ("non-native" formats, ex: 3D model formats) build their own preview generators internal to their application which is installed in Windows). Explorer just does the handshake between the Preview Pane and the underlying "parent" application to get the preview. (and probably searches cache first). I am struggling with my words, but you get the point... i think... Whether that theory is true or not, the fact remains that whatever Windows is actually doing under the hood to serve a preview image, no code library out there is going to match it's ability. They simply don't exist. It is dynamic and far better than writing a script that can generate previews for maybe only 10 formats at best... Therefore, this makes accessing Explorer's Preview pane images the proper solution.
Where To Go:
So... Easy enough....
My question can be concluded by asking for some direction on how to achieve this in VBA. First, do you know a solution that exists already? If not, I suspect i'll need to use the Win API, which I'm not really experienced in. If that is the case, can someone point me in the right direction for this- if this is even feasible.
Thanks for your time
--Regards
----------------------------------------------
EDIT- SUPPORTED LINKS:
docs.microsoft preview-handlers
thumbnail-for-any-file-in-windows
c-sharp-get-thumbnail-from-file-via-windows-api