>loExcelApp = CREATEOBJECT(“Excel.Application”) >loWorkbook = loExcelApp.Workbooks.Open("D:\My Documents\XLFile.xls") local DisplayAlerts DisplayAlerts = loExcelApp.DisplayAlerts loExcelApp.DisplayAlerts= .f. >loExcelApp.Range('A1:Z1').Select >loExcelApp.Selection.Replace('Year 1', '2003') loExcelApp.DisplayAlerts=DisplayAlertsAm adding the function I always use as an example
&& expression.Replace(What, Replacement, LookAt, SearchOrder, MatchCase, MatchByte, SearchFormat, ReplaceFormat) && expression Required. An expression that returns a Range object. && What Required Variant. The string you want Microsoft Excel to search for. && Replacement Required Variant. The replacement string. && LookAt Optional Variant. Can be one of the following XlLookAt constants: xlWhole or xlPart. && SearchOrder Optional Variant. Can be one of the following XlSearchOrder constants: xlByRows or xlByColumns. && MatchCase Optional Variant. True to make the search case sensitive. && MatchByte Optional Variant. You can use this argument only if you’ve selected or installed double-byte language support in Microsoft Excel && True to have double-byte characters match only double-byte characters. False to have double-byte characters match their single-byte equivalents. && SearchFormat Optional Variant. The search format for the method. && ReplaceFormat Optional Variant. The replace format for the method. * XlLookAt #DEFINE xlPart 2 #DEFINE xlWhole 1 * XlSearchOrder #DEFINE xlByColumns 2 #DEFINE xlByRows 1 function SearchAndReplace_ExcelSheet lparameters ExcelSheet, SearchFor, ReplaceWith, MatchCase, MatchWholeWord local DisplayAlerts DisplayAlerts = ExcelSheet.Parent.Parent.DisplayAlerts ExcelSheet.Parent.Parent.DisplayAlerts = FALSE =ExcelSheet.UsedRange.Replace(SearchFor, ReplaceWith, iif(MatchWholeWord, xlWhole, xlPart), xlByColumns, MatchCase) ExcelSheet.Parent.Parent.DisplayAlerts = DisplayAlerts endfunc *--------------------------------------------------------------------------