Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LastCell : Excel Automation
Message
De
25/02/2005 14:28:50
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Titre:
LastCell : Excel Automation
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
00990663
Message ID:
00990663
Vues:
58
Hi All,

In the block of code below I need to determine the RANGE of an Excel sheet. I need to know the designation of the 'LastCell'. By default I'm using 'IV64000'. But I'd like a quick way to determine the actaul one. This all works. But why Copy & Paste to unused cell! I'd like to just do the cells with data.

Below 'pcXlsFile' == The name of the Excel file passed to this procedure.
* Create an instance of EXCEL.
loExcelApp = CREATEOBJECT("excel.application")
* This will turn off the EXCEL 'SAFETY' messages.
loExcelApp.DisplayAlerts = .F.
* Open the file that the user selected for Import.
loExcelWb = loExcelApp.Workbooks.OPEN(pcXlsFile)
* Select the sheet
loExcelSheet = loExcelWb.ActiveSheet
* Select all the cells in the desired range.
loExcelSheet.Range("A1:IV64000").Select
* Copy all the info in the cells to the clipboard
loExcelSheet.Range("A1:IV64000").Copy()
* Select the 1 cell
loExcelSheet.Range("A1").Select
* This will paste the VALUES of the previously selected cells back inytp themselves.
loExcelSheet.Range("A1").PasteSpecial( -4163, -4142 )
* Save the change done on the previous line
loExcelWb.SAVEAS( pcXlsFile )
* Close the EXCEL file
loExcelWb.CLOSE
* Exit the Excel program
loExcelApp.Quit	&& Important!!
* Release the variables used for the Excel objects.
RELEASE loExcelSheet
RELEASE loExcelWb
RELEASE loExcelApp

IMPORT FROM '&pcXlsFile' TYPE XL8
TIA
Mike

VFP6 SP5
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform