Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combining XLS files into one workbook
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01035967
Message ID:
01102318
Vues:
21
>>Sergey,
>>
>>Thanks for the tip! Now, who has done this and might you have some code you might be willing to share?
>>
>>Thanks!
>
>oExcel = CREATEOBJECT("Excel.Application")
>DIMENSION MyExcelFiles[5]
>MyExcelFiles[1] = "c:\XlsF1.XLS"
>MyExcelFiles[2] = "c:\XlsF2.XLS"
>MyExcelFiles[3] = "c:\XlsF3.XLS"
>MyExcelFiles[4] = "c:\XlsF4.XLS"
>MyExcelFiles[5] = "c:\XlsF5.XLS"
>
>oExcel.WorkBooks.Open(MyExcelFiles[1])
>cActive = oExcel.ActiveWorkbook.Name
>FOR nXLS = 2 TO 5
>    ** Because COPY TO XL produce only one sheet we must insert a new one here
>    oExcel.ActiveWorkbook.Sheets.Add()
>    oExcel.WorkBooks.Open(MyExcelFiles[nXLS])
>    cNewBook = oExcel.ActiveWorkbook.Name
>    oExcel.ActiveWorkbook.ActiveSheet.Cells.Select()
>    oExcel.Selection.Copy()
>    oExcel.Windows(oActive).Activate
>    oExcel.ActiveWorkbook.ActiveSheet.Paste()
>    oExcel.Windows(cNewBook).Activate
>    oExcel.ActiveWorkbook.Close()
>    oExcel.Windows(oActive).Activate
>NEXT
>oExcel.ActiveWorkbook.Save()
>oExcel.Quit()
>oExcel = NULL
>RELEASE oExcel
>
>Something like that

Great code. But as I see in yours and Craig examples, you add new sheets with the informaiton to the first file, e.g. modifying the first Excel file. I was wondering if it's possible to do the same using a new clean file as output and don't touch the files from array?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform