Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ole excel cells 3130 OLE Terminate Bad OLE Channel error
objCell = objExcel.ActiveCellIn the "GetExcel" subroutine
This took me a while to figure out where the problem was...
I believe the problem occured, because the ActiveCell property fails if the active
sheet isn't a worksheet,the example activates Sheet1 before using the ActiveCell property.
;;;;;;;;;;;;;;;;;;;;;;;;OLE & EXCEL SCRIPT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This script is designed to read the text out of the cell in Excel. ; It will consecutively read through ten columns, and up to ten rows ; in each column ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; objExcel = "" GoSub GetExcel FHandle = FileOpen("c:\ThisTest.TXT","Append") GoSub ReadData objExcel.Quit ObjectClose(objExcel) Exit :GetExcel objExcel = ObjectOpen("Excel.Application") objExcelsheet = ObjectOpen("Excel.Sheet") objWrkBooks = objExcel.WorkBooks ;Because the ActiveCell property fails if the active sheet isn't a worksheet, ;the example activates Sheet1 before using the ActiveCell property. objCell = objExcelsheet.ActiveSheet objExcel.Visible = @True Return :ReadData Exists = FileExist("C:\Temp\Test.XLS") If Exists Then objWrkBooks.OpenText("C:\Temp\Test.XLS") Else Message("","Cannot Open File") Exit EndIF For x = 1 to 10 data = "" For z = 1 to 10 objExcel.Goto("R%x%C%z%",) objCell = objExcel.ActiveCell data = objCell.Value message("data",data) FileWrite(FHandle,data) Next Next Return
; Performs a calculation in an Excel spreadsheet. ;------------------------------ amount = "50.00" taxrate = ".0865" ;------------------------------ Book = ObjectOpen("Excel.Sheet") Sheet = Book.ActiveSheet CellA1 = Sheet.Range("A1") CellA2 = Sheet.Range("A2") CellA3 = Sheet.Range("A3") CellA1.Value = amount CellA2.Value = taxrate CellA3.Formula = "=A1*A2" tax = CellA3.Value ObjectClose(CellA3) ObjectClose(CellA2) ObjectClose(CellA1) ObjectClose(Sheet) ObjectClose(Book) Message("Tax", tax)
Article ID: W13674
Filename: OLE Excel Example that reads text from cells.txt
File Created: 1999:04:15:16:55:36
Last Updated: 1999:04:15:16:55:36