Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel OLE Automation
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Excel OLE Automation
Divers
Thread ID:
00672838
Message ID:
00672838
Vues:
45
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
Fil
Voir

Click here to load this message in the networking platform