WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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 = ObjectCreate("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

;EXA.Quit() 
EXA = 0
exit

Article ID:   W14694
Filename:   Excel Worksheet Change.txt
File Created: 2012:10:05:10:52:38
Last Updated: 2012:10:05:10:52:38