Dear Yuri
Sorry for wasting your time by not being specific in the first place.
Here is the exact scenario.
The App. runs a select which retrieves a set of fields from my VFP Table. The user exports the result to an excel spreadsheet ( copy to type xl5 ).
One of the fields, which is also exported, is a primary key for the table.
The user then works on the spreadsheet, mainly editing some fields, doing some calculations, deleting rows ( but not adding new ones ) etc...She does not add any column nor she touches the first row containing the titles nor she deletes the primary key column.
Then she saves the worksheet, and i want now to bring back all the changes from the spreadsheet to the original VFP table.
So i have there some code that looks like this
lLastRow = oxl.ActiveSheet.UsedRange.Rows.Count
SELECT Docu
SET ORDER TO Codigo
FOR lRow = 3 TO lLastRow
lCodigo = oxl.Cells( lRow, 1 ).Value
SEEK lCodigo
IF !FOUND()
LOOP
ENDIF
WITH oxl
replace PaisTema WITH .Cells(lRow,2).Value,;
Titulo WITH .Cells(lRow,3).Value,;
DistriReal WITH .Cells(lRow,4).Value,;
IndiceAI WITH .Cells(lRow,5).Value
ENDWITH
ENDFOR
The REPLACE clause fails when a field ( for instance DisTriReal ) is of type date.
Thanks for your patience
Jaime
>>>>Hi
>>>>I create an excel file from my file ( copy to ... type xl5 ). After some work on the worksheet, i want to update my table back. It keeps erroring in the date field when bringing it back. Is there an easy way to achieve this without creating a date string, importing there then moving it from VFP?
>>>>
>>>>Thanks
>>>>Jaime
>>>
>>>Hi Jaime,
>>>
>>>It depends on what is going on with "some work on the worksheet", and you "update my table back". I do not think that you will see errors with the plain calls like:
>>>
>>>copy to (ExcelFile)... xl5
>>>append from (ExcelFile) xl5
>>>
>>>What are errors related to yours "keeps erroring in the date field"? And what are you doing with the information in Excel file?
>>
>>Well the application scans the worksheet ( i.e for each row ) and does a REPLACE command on the table. When replacing VFPDateField with ExcelDateField i get an error. I tried running stuff like .Range('D:D').NumberFormat='dd-mm-yyyy' but still no go.
>>
>>Jaime
>
>And there is another similar question, what do you mean, "replacing VFPDateField with ExcelDateField"? What is ExcelDateField?
>
>Anyway, I doubt you would have problem following scenario like this:
>
>
>create curs yy (fldt, D)
>insert into yy values (date())
>copy to c:\yy xl5
>
>oExcel= CREATEOBJECT("Excel.Application")
>
>with oExcel
> .DisplayAlerts = .f.
> .Visible=.t.
> .Workbooks.Open("c:\yy.xls")
>ENDWITH
>......
>
>REPLACE fldt WITH OExcel.Activesheet.Cells(2,1).value
>.....
>
>
>
>Still it is not quite clear what do you mean, "some work on the worksheet", which may also be critical to derive the answer to your original question.
>Do you change formattings of the cells, insert something manually, or what?
Why do programs stop working correctly as soon as you leave the Fox?