----------
Custom Search

Wednesday, July 8, 2009

Visual Foxpro and Excel

*Open Desired Excel File
mfile=getfile('xls','Open Excel','Browse',1)

*Create Object for Excel Application
oleExcel = CREATEOBJECT("Excel.Application")

*Open the Excel File
oleExcel.Workbooks.Open(mFILE)

*Choose Sheet to use (eg. Sheet1, Sheet2, etc...)
oleSheet = oleExcel.Sheets(1)

*Save Value from Excel to a Variable excelvalue
excelvalue=oleSheet.Cells(1,1).value

*Save Value to Excel
oleSheet.Cells(1,1).value="Hello World"

*Show or Hide Excel File
oleExcel.Visible = .t.

*Quit the Opened Excel File
oleExcel.quit

No comments:

Post a Comment