General information
Category:
COM/DCOM and OLE Automation
Title:
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only