WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Determine Version That An Excel File Was Saved In


;Winbatch 2006C - Ever Wonder which version an
;                 Excel file was saved in
;
;Stan Littlefield, August 12, 2006
;//////////////////////////////////////////////////////////////////////////////
GoSub udfs
cXLS = AskFilename("Open Spreadsheet", DirScript(), "Excel Files|*.xls|", "", 1)
If cXLS=="" Then Exit
BoxOpen("Please Wait","Examining Selected Excel File")
oXL=CreateObject("Excel.Application")
oXL.Visible          = 0  ;initially set this to 1 to test
oXL.ScreenUpdating   = 1
oXL.UserControl      = 1
oXL.DisplayAlerts    = 0
oXL.EnableEvents     = 1
oXL.WorkBooks.Open(cXLS)
cRet = Getxlstuff()
oXL.Quit()
oXL=0
BoxShut()
Message(cXLS,cRet)
Exit
;////////////////////////////////////////////////////////////////////////////
:udfs
#DefineSubRoutine getxlstuff()
retval="Opening With Version "
cVer = oXL.Version
Select Int(cVer)
   Case 7
      retval = StrCat(retval,"Excel - 95",@CRLF)
      Break
   Case 8
      retval = StrCat(retval,"Excel - 97",@CRLF)
      Break
   Case 8
      retval = StrCat(retval,"Excel - 2000",@CRLF)
      Break
   Case 10
      retval = StrCat(retval,"Excel - 2002",@CRLF)
      Break
   Case 11
      retval = StrCat(retval,"Excel - 2003",@CRLF)
      Break
EndSelect
retval = StrCat(retval,"File Saved In - ")
nFormat = oXL.ActiveWorkbook.FileFormat
Select nFormat
   Case -4143
      retval = StrCat(retval,"Excel: 2000 Plus Through 2003",@CRLF)
      Break
   Case 16
      retval = StrCat(retval,"Excel Sheet: 2.1",@CRLF)
      Break
   Case 29
      retval = StrCat(retval,"Excel Sheet: 3",@CRLF)
      Break
   Case 33
      retval = StrCat(retval,"Excel Sheet: 4",@CRLF)
      Break
   Case 35
      retval = StrCat(retval,"Excel: 4",@CRLF)
      Break
   Case 39
      retval = StrCat(retval,"Excel: 5",@CRLF)
      Break
   Case 43
      retval = StrCat(retval,"Excel: 5.0/95 through 97/2000",@CRLF)
      Break
   Otherwise
      retval = StrCat(retval,"Unknown or saved in 2003 and above!",@CRLF)
EndSelect

Return(retval)
#EndSubRoutine

Return
;////////////////////////////////////////////////////////////////////////

Article ID:   W17149
File Created: 2007:07:03:14:28:30
Last Updated: 2007:07:03:14:28:30