Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Give this code a try:
ifile="spreadsheet.xls" buf=binaryalloc(filesize(ifile)) binaryread(buf,ifile) ;build the search string str=strcat(num2char(6) ,num2char(5)) ;find it and move forward three spaces pos=binaryindex(buf,0,str,@FWDSCAN) + 3 ;here they are buildID=binarypeek2(buf,pos) buildYear=binarypeek2(buf,pos+2) binaryfree(buf)
I tried it on my oldest and newest spreadsheets, seems to work.
In the MS Excel SDK there exists an utility called BIFFVIEW.EXE that might play with the excel specific record types. I think the BIFFVIEW can read the recordtype BOF (ID = 0x0009 resp. 0x0209 ... resp. 0x0809) from all excel file versions. Once you have the BOF record isolated, the version number can be extracted from this record.
Another way can be the COM utility MSOFILE.DLL from Microsoft. Because this module looks for the file properties, it might not deliver results for each excel file. If there is no property embedded, then the COM module fails. But it is worth a try. See attachment.
;------------------------------------------------------------------------------------------------------------------------------------------ IntControl(73,2,0,0,0) ; Gosub the label :WBERRORHANDLER. ; The OLE Document Property Reader COM module. sOLEDLL = "D:\TEMP\DSOFILE.DLL" ; <== Change path to your needs. ; Register the COM component. iResult = DllCall(sOLEDLL,long:"DllRegisterServer") If iResult Then Exit ; Terminate immediately. ; We work with a prepared list of excel filenames. sFilename = "D:\TEMP\FileList.Excel.txt" sList = "" ; Set size of internal FileRead buffer. iLastFRSize = IntControl(65,4096*64,0,0,0) hFR = FileOpen(sFilename,"READ") oDSO = ObjectOpen("DSOleFile.PropertyReader.1") While @TRUE sLine = FileRead(hFR) If (sLine=="*EOF*") Then Break If (sLine=="") Then Continue sVersion = "N/A" iLastErrorMode = ErrorMode(@OFF) oDocProp = oDSO.GetDocumentProperties(sLine) iLastError = LastError() If oDocProp sVersion = oDocProp.Version ObjectClose(oDocProp) EndIf sList = StrCat(sList,sVersion,"|",sLine,@LF) EndWhile ObjectClose(oDSO) ; Unregister the COM component. iResult = DllCall(sOLEDLL,long:"DllUnregisterServer") FileClose(hFR) IntControl(63,100,200,900,700) ; Sets coordinates for AskFileText, AskItemList and AskTextBox windows. AskItemList("Version",sList,@LF,@SORTED,@SINGLE) Exit ;------------------------------------------------------------------------------------------------------------------------------------------ :WBERRORHANDLER Return ;------------------------------------------------------------------------------------------------------------------------------------------
Article ID: W15973
File Created: 2004:03:30:15:42:06
Last Updated: 2004:03:30:15:42:06