Extract Worksheet from Workbook of Excel using Foxpro 
Author Message
 Extract Worksheet from Workbook of Excel using Foxpro

Greetings!

I was thinking of writing a program to extract and display all the worksheet
from a Excel Workbook.
Then using combobox to select the worksheet the user then import only the
relevant worksheet using
IMPORT FROM WorkbookName.xls TYPE XL5 SHEET WorkSheetName

Anyone knows whether there is a function or method in doing this, or can
this be done?

Thank you.

Warmest regards,



Mon, 03 Feb 2003 03:00:00 GMT  
 Extract Worksheet from Workbook of Excel using Foxpro

Hi

I would do this with a COM-Automation of Excel. You can create an instance of
Excel, open your Workbook and then read the names of all contained Worksheets.

Something like the following code (untested!)

loExcel = createobject("Excel.Application")
loExcel.Workbooks.Open("c:\myWorkbook.xls")
dimension lacSheets(loExcel.Workbooks(myWorkbook).Worksheets.Count)
for i = 1 to loExcel.Workbooks(myWorkbook).Worksheets.Count
 lacSheets(i) = loExcel.Workbooks(myWorkbook).Worksheets(i).Name
endfor

You now have an Array lacSheets which contains the names of all Worksheets. You
can use this Array as rowsource for your combobox and in the interactivechange
or valid-event you can put your import-code.

Hope this helps

Thanks
Michael Daenzer

Quote:
> < I was thinking of writing a program to extract and display all the worksheet

> < from a Excel Workbook.
> < Then using combobox to select the worksheet the user then import only the
> < relevant worksheet using
> < IMPORT FROM WorkbookName.xls TYPE XL5 SHEET WorkSheetName
> <
> < Anyone knows whether there is a function or method in doing this, or can
> < this be done?

> < Thank you.

> < Warmest regards,



Mon, 03 Feb 2003 03:00:00 GMT  
 Extract Worksheet from Workbook of Excel using Foxpro
Thanks for the info.
There was some error though but I mangae to continue from your lead.

The tested code will read.
loExcel = createobject("Excel.Application")
loExcel.Workbooks.Open("c:\myWorkbook.xls")
dimension lacSheets(loExcel.Workbooks.application.Worksheets.Count)
for i = 1 to loExcel.Workbooks.application.Worksheets.Count
 lacSheets(i) = loExcel.Workbooks.application.Worksheets(i).Name
endfor

Thanks again!


Quote:

> Hi

> I would do this with a COM-Automation of Excel. You can create an instance
of
> Excel, open your Workbook and then read the names of all contained
Worksheets.

> Something like the following code (untested!)

> loExcel = createobject("Excel.Application")
> loExcel.Workbooks.Open("c:\myWorkbook.xls")
> dimension lacSheets(loExcel.Workbooks(myWorkbook).Worksheets.Count)
> for i = 1 to loExcel.Workbooks(myWorkbook).Worksheets.Count
>  lacSheets(i) = loExcel.Workbooks(myWorkbook).Worksheets(i).Name
> endfor

> You now have an Array lacSheets which contains the names of all
Worksheets. You
> can use this Array as rowsource for your combobox and in the
interactivechange
> or valid-event you can put your import-code.

> Hope this helps

> Thanks
> Michael Daenzer

> > < I was thinking of writing a program to extract and display all the
worksheet

> > < from a Excel Workbook.
> > < Then using combobox to select the worksheet the user then import only
the
> > < relevant worksheet using
> > < IMPORT FROM WorkbookName.xls TYPE XL5 SHEET WorkSheetName
> > <
> > < Anyone knows whether there is a function or method in doing this, or
can
> > < this be done?

> > < Thank you.

> > < Warmest regards,



Tue, 04 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Fox to Excel with Multiple Worksheets in a Workbook

2. UnHidding Excel Workbooks using VB5

3. Automatically generating Excel workBooks from Foxpro tables

4. Extract data from MS Excel spreadsheet to Foxpro 2.6 dbf format

5. Cant open Excel Workbook

6. Exporting to multi-sheet Excel workbook

7. Excel Workbooks

8. Excel workbook activex and Word activeX

9. Import Excel 5.0 worksheet into FPD 2.6

10. Import Excel 5.0 worksheet into FPD 2.6?

11. Excel always crashes after I close a worksheet?

12. Export a query to Excel worksheet

 

 
Powered by phpBB® Forum Software