Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Writing to an excel file
Message
De
10/05/2011 13:11:56
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Divers
Thread ID:
01510189
Message ID:
01510192
Vues:
62
>>Hi All:
>>
>>I'm trying to populate an Excel file with values using automation, but nothing gets written. What am I doing wrong?
>>
>>This is the code:
>>
>>
>>LOCAL loExcel AS Excel.APPLICATION
>>
>>loExcel = CREATEOBJECT("Excel.application")
>>loExcel.VISIBLE = .F.
>>
>>loWorkBook = loExcel.Workbooks.OPEN('P:\Flock Information.xls')
>>loExcel.displayalerts = .F.
>>
>>loWorkBook.Sheets("28 Day").SELECT
>>
>>FOR i = 288 TO 300
>>	legRow = 'M' + ALLTRIM(STR(i))
>>	loWorkBook.ActiveSheet.RANGE("&legRow").select
>>	loExcel.ActiveCell.Value = ALLTRIM(STR(i))   &&<--- This doesn't work
>>*!*		loWorkBook.ActiveSheet.RANGE("&legRow").Value = ALLTRIM(STR(i))  &&<---- This doesn't work either
>>NEXT
>>
>>
>>*  Hardcoding the range also does not work
>>loWorkBook.ActiveSheet.RANGE("M288").select
>>loExcel.ActiveCell.Value = "Hello"	
>>
>>* Execute this code just to make sure there is a connection, and IT WORKS
>>lcTest = loWorkBook.ActiveSheet.RANGE("L288").VALUE
>>? lcTest
>>	
>>loExcel.displayalerts = .F.
>>loExcel.QUIT()
>>RELEASE loExcel
>>loExcel = NULL
>>
>>
>>Thanks,
>>
>>Yossi
>
>What is "active cell" ? You do not activate cell in your code. "Select" and "activate" may mean different things.
>Call cell directly, like loWorkBook.ActiveSheet.RANGE("M288").value="Hello"
>
>Other than that, how about saving the file?

Yuri:

It was the absence of the save.

Thanks for your help!

Yossi
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform