Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Extracting a few cells from an excel spreadsheet
Message
 
To
05/01/2009 22:31:14
Neil Mc Donald
Cencom Systems P/L
The Sun, Australia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01371276
Message ID:
01371570
Views:
14
OK, thanks for the ideas.

It was easy, here is a sample that works for me:
#define xlLastCell 11
#define xlMaximized -4137
#define xlRangeAutoformatClassic2 2
#define xlPortrait 1


LOCAL lcFileName

* Get file name to open 
lcFileName = GETFILE()

* make sure the reference is null first
oExcel = .null.


* then open excel and make the data look good, like this
oExcel = CreateObject("Excel.Application")
if vartype(oExcel) != "O"
  * could not instantiate Excel object
  * show an error message here
  return .F.
endif


* open the workbook you just created
oWorkbook = oExcel.Application.Workbooks.Open(lcFileName)

* turn off alerts
oExcel.DisplayAlerts = .F.

* dont need it visible just need info from it
oExcel.visible = .f.

*!*	* rename the Sheet to whatever you like
*!*	oActiveSheet = oExcel.ActiveSheet
*!*	oActiveSheet.Name = "MyData"

*!*	oExcelApp = oExcel.Application
*!*	oExcelApp.WindowState = xlMaximized


* display values for testing purposes
? oExcel.Range("b2").Value 
? oExcel.Range("b3").Value 
? oExcel.Range("b4").Value 
? oExcel.Range("b5").Value 
? oExcel.Range("b6").Value 
? oExcel.Range("b7").Value 
? oExcel.Range("b8").Value 
? oExcel.Range("b9").Value 
? oExcel.Range("b10").Value 
? oExcel.Range("b11").Value 

* done, remove reference
oExcel = .null.


RETURN
Previous
Reply
Map
View

Click here to load this message in the networking platform