Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem populating a VFP table with an Excel 'date' fiel
Message
De
03/03/2000 14:58:26
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00340955
Message ID:
00341437
Vues:
27
I just tested this further, the following code does work.
I'm sorry I posted the wrong code, I feel like a jerk.
But as you see by this code.
A DateTime is the result.
A simple TTOD() conversion,
No other functions to consult.

No need for Date1904
But it's really an Excel call
You can try it with oExcel.Activeworkbook.Date1904
It's just not needed here at all.


* Assumes oExcel = Excel App object and a sheet is opened with a numeric value in Cell A1 with a date format

?TTOD(oExcel.Activeworkbook.ActiveSheet.Cells(1,1).Value)

Returns {07/24/1999}



>I am using Excel 2000 and VFP 6 SP3. I have ended up making the field a text field in Excel and checking/correcting the format and converting to date before populating the table in FoxPro. This should work in most cases...
>
>But I would really like to make it right. If anybody has the answer please let me know!
>
>Thanks for your help
>
>>I'm not sure. Date1904 is a boolean property of a Workbook object. The example in the Excel 2000 Language Reference is "ActiveBook.Date1904 = True". If you are using an earlier version of Excel,perhaps that property doesn't exist. If not, then skip that part and try one of the two date calcs. I believe the default is 01-01-1901+Serialno. Try it.
>
>>> Thats the serialize data value. First off, you have to figure out which date > system is being used, then convert:
>>
>>> WITH oExcel.ActiveBook
>>> IF .Date1904
>>> dDate={^1904-01-02}+VAL(.ActiveCell.FormulaR1C1)
>>> ELSE
>>> dDate={^1901-01-01}+VAL(.ActiveCell.FormulaR1C1)
>>> ENDIF
>>
>>Thanks for the help, I'm sure that the answer is near but I'm still having problems. Here is my code:
>>
>>oExcel= CREATEOBJECT("Excel.Application")
>>WITH oExcel
>>.DisplayAlerts= False
>>.workbooks.open(thisform.FileName)
>>.Range("C6").Select
>>
>>If I use this code:
>>IF .Date1904
>>I get "OLE error code 0x80020006: Unknown name."
>>
>>If I use this code:
>>IF .ActiveBook.Date1904
>>I get "Member ACTIVEBOOK does not evaluate to an object."
>>
>>If I use this code:
>>IF .WorkBook.Date1904
>>I get "Member WORKBOOK does not evaluate to an object."
>>
>>Am I possibly missing something in my header file?
>>
>>Thanks
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform