Please ignore this entire thread.
I was reporting a real problem and I have resolved it.
Turns out I had some weird combination of a form where DataToClip was being invoked before the form ever had focus, and DataToClip was then refering to the calling form's datasession. Don't ask why I'm doing that; I wouldn't do that now, and don't know why I did it then.
In any case, problem is gone.
>Dragan --
>
>Unfortunately, that was not the cure. It seems that it is selecting a table from some other DataSession!!
>
>Really weird. And frustrating.
>
>I had noted that this export routine was called twice here, something I had not done before. I removed the other call, and it still fails, so that's not part of the problem.
>
>Curiously, even _VFP.DatatoClip( alias(), 99999, 3) doesn't work!
>
>
>
>>>I'm having problems with the following code:
>>>
lcStruct = Sys(2015)
>>>Select &lcFields From (lcAlias) Into Cursor (lcStruct) readwrite Where Recno()<=lnThruRecno+1
>>>
>>>Afields(filestruct, lcStruct)
>>>
>>>*** and use {datatoclip} to paste these columns into Excel
>>>loMsg.Progress("Writing Data")
>>>_Cliptext = ''
>>>_vfp.DataToClip(lcStruct, 99999, 3)
>>>The problem I am getting, at times, occurs on the last line. I get the error message
>>>
OLE IDispatch exception code 0 from Visual FoxPro for Windows: 13 :Alias is not found...".
>>>
>>>The most curious thing about this is that I can resume execution (on the same line) and it works correctly!
>>>
>>>Now, one additional piece of information. I have been using this code for years. It's used every day. However, what
has changed is that this program is, for the first time ever, called twice in a row (it's exporting a grid to Excel). However, I have a hard time seeing the relevance -- note the call to AFields(), which uses the same cursor name correctly. So why would DataToClip think the cursor does not exist?
>>>
>>>More importantly -- anybody have any suggestions of a way around this?
>>
>>I did this a lot, and I don't remember ever passing parameters. Try
>>
>>select (lcStruct)
>>_vfp.datatoclip(,,3)
>>
>>Omitted parameters default to current alias and all records. So no need to pass them.
Jim Nelson
Newbury Park, CA