Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Excel Worksheet Change

 Keywords:  Excel Worksheet Sheet

Question:

I have an excel file that I am reading that has two sheets, reading the first is no problem, but I need to read the second. How can this be done?

Answer:

;Define .XLS file and sheetname to activate
EXF = "C:\WINDOWS\DESKTOP\OLE-ADO-ADOX\test.XLS"
Worksheetname = "Sheet2"

;Open Excel
EXA = ObjectOpen("Excel.Application")
EXA.Visible = @TRUE
;Open XLS file
MyWorkbook = EXA.workbooks
MWO = MyWorkbook.open(EXF)
;Get active workbook object
AWB = EXA.activeworkbook
;get worksheet object 
AWS = AWB.worksheets(Worksheetname)
;Activate worksheet
AWS.Activate 
ObjectClose(EXA)
exit

Article ID:   W14694
Filename:   Excel Worksheet Change.txt