Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE Message in Excel 2002
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
OLE Message in Excel 2002
Miscellaneous
Thread ID:
00822245
Message ID:
00822245
Views:
34
I have a routine in VFP that uses Excel Automation to do some data manipulation on an exported Excel workbook. I’m using the REPLACE automation function to change values in a selected range of cells. My code looks something like this…

loExcelApp = CREATEOBJECT(“Excel.Application”)
loWorkbook = loExcelApp.Workbooks.Open("D:\My Documents\XLFile.xls")
loExcelApp.Range('A1:Z1').Select
loExcelApp.Selection.Replace('Year 1', '2003')

When running Excel 2002, a dialog message often appears saying: “Microsoft Excel cannot find any data to replace. Check if your search formatting and criteria are defined correctly…”. I believe the reason for this message is that the character string (“Year 1” in the code above) isn’t contained in any of the cells being searched, which is likely given what I'm attempting to do. However, I want Excel to simply continue silently when nothing is found, and not prompt me or my users. If Excel 2000 or Excel 97 are used as the automation engine this message didn't get generated, so it appears to be something added by MS in this latest Excel release.

This message is very annoying and, in my opinion kind of useless, and I’d very much like to avoid its generation. I’d either like to know a way of turning it off, preferably via automation code, or adding code to check to see if the original text exists in the first place, and if not, skipping the replace function altogether. Can anyone help?

TIA
- Dave
Dave
Next
Reply
Map
View

Click here to load this message in the networking platform