Article ID: 142193
Article Last Modified on 7/13/2004
Enter In Cells
----------------------------
Part # A1
Sales YTD B1
1 A2 through A4
2 A5 through A7
3 B2 through B7
C:\XLSheets\Testbook.xls.
*** Program oleExcel.prg *****
#DEFINE xlLandscape 2
#DEFINE xlDoNotSaveChanges 2
DIMENSION laDemoData(4) && For some Visual FoxPro users, data
laDemoData(1)= 1024 && could come from table or view
laDemoData(2)= 2048
laDemoData(3)= 5120
laDemoData(4)= "The Sample Message"
loExcel = CREATEOBJECT("Excel.application")
WITH loExcel
.Application.Workbooks.Open("C:\XLSheets\testbook.xls")
.Application.Worksheets("Sheet3").Activate && Select sheet
.Range("b2").Value = 14444 && constants as data
.Range("b3").Value = 25555
.Range("b4").Value = 30001
.Range("b6").Value = laDemoData(1) && variables as data
.Range("b7").Value = laDemoData(2)
.Range("b8").Value = laDemoData(3)
.Range("a12").Value = laDemoData(4)
.Worksheets("Sheet3").PageSetup.Orientation = xlLandscape
.ActiveSheet.PrintOut && Example of printing the worksheet
.Visible = .t. && See the results
=MESSAGEBOX("Click OK to close Excel.") && Keep the program running,
&& so Excel isn't stranded
.ActiveWindow.Close(xlDoNotSaveChanges)
.Quit()
ENDwith
139051 How To Select Cells in Microsoft Excel by Using OLE Automation
132535 PRB: Releasing Object Variable Does Not Close Microsoft Excel
138398 PRB: Release may not Remove OLE Objects from Memory
130809 INFO: KB List: OCX, OLE, ODBC, & 3rd-party Interoperability
Additional query words: Interoperability printing
Keywords: kbhowto kbinterop kbcode KB142193