Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function to execute in MS Excel
Message
 
À
26/08/2012 06:28:13
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01551171
Message ID:
01551474
Vues:
87
This message has been marked as the solution to the initial question of the thread.
>Formula is in field "AD".
>
>>Excel version: MS EXCEL 2003 SP3
>>See attached file.
>>
>>>>I am trying to export a dbf to Ms excel with a the help of VFP2Excel function.
>>>>There is a field in dbf where I created an excel function but it wont execute when exported.
>>>>The function only executes when I open the MS Excel file and click on the cell.
>>>>How can I make the function execute automatically when exported to MS Excel?
>>>>
>>>>Thanks
>>>>T.
>>>
>>>So, if I understood it correctly, the problem is with Excel file having formula(s) in particular cell(s), and those formulas work only if user click on the cell. What is your Excel version? Can you provide example of Excel file having such a behavior?

As far as I understand, you did not use Excel automation to create the file, but you did it using plain copy to xls VFP command or such. As a result, formulas in cells recognized as text and their formulaR1C1 (or linked cells) are not recognized properly.
You need to set FormulaR1C1 explicitly, like:
xlDefault=-4143
oExcel=CREATEOBJECT("Excel.Application")
with oExcel
    .visible=.t.
    .workbooks.Open("c:\aaa.xls")
    FOR ia=2 TO .Activesheet.UsedRange.Rows.Count
	lc=.Range("AD"+TRANSFORM(ia)).Formula
	.Range("AD"+TRANSFORM(ia)).FormulaR1C1=""
	.Range("AD"+TRANSFORM(ia)).Formula=lc

* or just .Range("AD"+TRANSFORM(ia)).Formula = .Range("AD"+TRANSFORM(ia)).Formula

   ENDFOR
  .ActiveWorkbook.SaveAs(,xlDefault)
   .ActiveWorkbook.close
ENDWITH

oExcel.quit
oExcel= .NULL.
release oExcel
Good Luck


Good Luck
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform