View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming,borland.public.delphi.oleautomation
jodleren jodleren is offline
external usenet poster
 
Posts: 49
Default Excel 97 replace vs newer versions...

Hi!

I found that the Cells.Replace function has been updated from 97 to
XP. I do not have the versions in between and not totally aware of the
versions available. Anyway, I order to detect it I came up with this:

Val(ExcelApplication.Version, vers, i); // get the version no as
a number
FOldExcel := (i<0) or (vers<=8); // true for errors or max
version 8

Question: for 97 it is 8.0 - works well, but can it be with more that
one period?

Otherwise, the new "replace" would cause me problems, so my replace
looks like this:
Action wanted: replace strings such as ¤date¤ with e.g. 01.03.2010

// actual replace with respect to the Excel version!
if FOldExcel then
ExcelApplication.Cells.Replace(What := FOfficeReplaces[j],
Replacement := sTemp, LookAt := xlPart,
SearchOrder := xlByColumns, MatchCase := False) // ,
MatchByte := False can be added, does not change anything.
else
ExcelApplication.Cells.Replace(What := FOfficeReplaces[j],
Replacement := sTemp, LookAt := xlPart,
SearchOrder := xlByColumns, MatchCase := False,
SearchFormat := False, ReplaceFormat := False);

The "new" replace would cause an error in Excel 97: c:\whatever
\file.XLS\ could not be found.
The filename is correct but it adds a backslash.
The error message catched in my log is: OLE error 800A03EC

To sum up:

1) Now, my real problem is that it works in Excel XP, but the code for
Excel 97 does not cause any errors, but it does not carry out the
replace. Why?
2) For which versions of Excel is which version of Replace?

WBR
Sonnich