Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing from Excel 97 to VFP
Message
From
13/11/1999 02:06:32
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00290329
Message ID:
00290878
Views:
22
Jerry,

Open Excel. Start recording a macro. Select the data, copy, save as, or whatever you want to do. Stop the macro. Open the VB editor and see what the macro says.

You can take this code almost as-is into FoxPro.
oExcel = CREATEOBJECT([Excel.Application])
*!* oExcel = GETOBJECT( , [Excel.Application])
oExcel.Visible = .T.

WITH oExcel

	.Workbooks.Add
	.ActiveWorkbook.Sheets(1).Activate	
....

        .ActiveWorkbook.SaveAs((lcSaveFileName))
	.Quit	&& Quits Excel, otherwise still open and invisible

ENDWITH
One gotcha: when you're testing and you crash, release the objects or you'll very quickly get 10 copies of Excel and run out of memory.

I've had a lot of fun "driving" Excel this way.


>I've been given about 100 Excel 97 spreadsheets, and would like to extract the data from a particular named range (XDATA) that exists within each spreadsheet, and consolidate it into a single VFP database. I'm sure there's a way to consolidate the data using VBA, but I'm not familiar enough with that product to know where to start. There doesn't appear to be a native way to this in VFP. However, I wonder if anyone knows a way (perhaps using OLE) to do this. Thanks!!
Previous
Reply
Map
View

Click here to load this message in the networking platform