Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Reading data from Excel spreadsheets using Ole functions
Hello. I have a program which reads data from an Excel spreadsheet using the OleCreateInstance, OleGetProperty & OleCallMethod functions. Basically, it copies the data and I retrieve it by an OI Get_Property('CLIPBOARD', 'TEXT') call. This works most of the time, but sometimes it fails with no data found on the clipboard. I have error checking for all the ole function calls, but no errors are being reported. Does anyone any experience with this type of functionality and have any idea what is causing this problem? Thanks.
Comments
Is the current approach selecting the worksheet and copying that to the clipboard, or are you using a more granular approach and specifying particular ranges, for example, a row or an individual cell?
I assume you have checked the windows event viewer when this happens?
Neither of those sound too ominous for the copy sheet approach, especially when you say the same sheet works most of the time.
If you can be sure that there should be data, (specifically if you start using different sheets), perhaps you can have a three try loop, (or some other arbitrary number). It doesn't fix the problem, but if you had a loop, checked the contents of the clipboard and if empty, call the copy again with your fingers crossed, you might reduce the number of instances where a failure is an issue.
So with your experience, I'd come to the same conclusion, that it was environmental, and your hands are tied, but I understood, (perhaps incorrectly), that @rogercurtishall had a subtly different scenario.