Purpose of this function is to extract thumbnails from MS Office documents (docx,xlsx,pptx) if saved with thumbnails.
I suggest you first go through the disucssion about saving and extraction of thumbnails of office ducuments
viewtopic.php?f=3&t=13602.
If an office document docx, xlsx or pptx is saved with a thumbnail, this function extracts the thumbnail and saves in the same folder.
OfficeExtractImage( "c:\fwh\samples\cust.docx" ) --> "c:\fwh\samples\cust.emf" // empty value in case of failure
OfficeExtractImage( "c:\fwh\samples\cust.xlsx" ) --> "c:\fwh\samples\cust.wmf"
OfficeExtractImage( "c:\fwh\samples\mppt.pptxx" ) --> "c:\fwh\samples\mppt.jpeg"
Second parameter is lReExtract ( default .f. ). When .f., if the function finds an already extracted thumbnail, returns the name of the thumbnail file. When .t., the function re-extracts the thumbnail.
Notes:
1) The document must have been saved with "save thumbnail" option checked while saving.
2) OfficeExtractImage is named similar to IExtractImage interface.
The new class TXImage can display emf/wmf in addition to any image file that the TImage class handles. This is the most suitable viewer to view the thumbnails.
Testing:
You may Select any docx, which is saved with thumbnail.
For this illustration, I opened and saved c:\fwh\manual\manual FWH english.doc as c:\fwh\manual\FWHmanual.docx with thumbnail.
In addition, I used xbrowser with customer.dbf and saved as word document from the print preview as c:\fwh\samples\cust.docx and c:\fwh\samoles\cust.xlsx, with "save thumbnail" option checked.
When the docx and xlx are ready, here is a sample program to view:
#include "fivewin.ch"
//----------------------------------------------------------------------------//
function Main()
local aDocs := { "c:\fwh\manual\fwhmanual.docx", "c:\fwh\samples\cust.docx", "c:\fwh\samples\cust.xlsx" }
local oDlg, oFont, oBrw, oImage, oBrush
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-18
DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\backgrnd\stone.bmp"
DEFINE DIALOG oDlg SIZE ScreenWidth() * 0.6, ScreenHeight() * 0.95 PIXEL ;
FONT oFont TRUEPIXEL TITLE "FWH 15.04: OFFICE THUMBNAIL VIEWER"
@ 20,20 XBROWSE oBrw SIZE 300,-20 PIXEL OF oDlg ;
DATASOURCE aDocs COLUMNS 1 HEADERS "Document" ;
CELL LINES NOBORDER
WITH OBJECT oBrw
:bChange := { || oImage:Refresh() }
:CreateFromCode()
END
@ 20,320 XIMAGE oImage SOURCE OfficeExtractImage( oBrw:Document:Value ) SIZE -20,-20 OF oDlg
oImage:SetBrush( oBrush )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
RELEASE BRUSH oBrush
return nil
//----------------------------------------------------------------------------//
Note:
The function in the released version works with xHarbour but not with Harbour, due to some bugs in Harbour's HB_UnzipFile() function. The fix/woraround for Harbour is ready and will be released soon.