Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Excel OLE Automation
Hi,
Rick Strahl had a very interesting article on Web charting, but I could not download the Microsoft class required for it - temporary unavailable.......
So I trying the "good old" Excel automation for charting.
A collegue of mine created a complicated Excel Workbook template with a few tabs with charts.
Then, I created a routine from my appication which creates an Excel Workbook.
The first step of the OLE automation is to copy a worksheet from one workbook to another:
***************************
#DEFINE True .T.
#DEFINE False .F.
LOCAL lo1Excel, lo2Excel, lcOldError
lcOldError = ON("ERROR")
ON ERROR lo1Excel = .NULL.
lo1Excel = GetObject("C:\ecr_rpt.xls","Excel.Application")
IF ISNULL(lo1Excel)
lo1Excel = CreateObject("Excel.Application")
lo1Excel.Application.Workbooks.Open("C:\ecr_rpt.xls")
ENDIF
WITH lo1Excel.Application
.Visible = .T.
.Windows("ecr_rpt.xls").Activate
.WorkSheets("ecr_rpt").Select
.ActiveSheet.Copy
ENDWITH
lo2Excel = GetObject(gcDrv+":\cfg\ECR_Report.xls")
RELEASE lo1Excel
WITH lo2Excel.Application
.Windows("ECR_Report.xls").Activate
.WorkSheets("ecr_rpt").Select
.ActiveSheet.Paste
ENDWITH
ON ERROR &lcOldError
*****************************
The above did not do what it was supposed to do and also left an instance of OLE hanging.
Any ideas?
Thanks, Jonathan
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement