Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel OLE Automation
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Excel OLE Automation
Miscellaneous
Thread ID:
00672838
Message ID:
00672838
Views:
46
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
Map
View

Click here to load this message in the networking platform