Push Code into Excel using OLE
Keywords: Push Code into Excel using OLE
Question:
I have an excel spreadsheet (template) created in a directory... for the life of me, i cannot figure out how to write the code to simply open an existing spreadsheet so that i can push data into. i realize this is basic stuff. You can laugh, but please assist. Thanks.Answer:
Try attached Example. It pushed code into Excel using OLE...; ******************************************************************************** ; * ; * Excel OLE Sample ; * ; ******************************************************************************** objXL = ObjectOpen("Excel.Application") objXL.Visible = @TRUE Workbooks=objXL.WorkBooks Workbooks.Add Numbers="One Two Three Four Five Six Seven Eight Nine Ten" offset=1 row=0 :ROWLOOP col=0 row=row+1 if row > 10 then goto byebye strValue=ItemExtract(row,Numbers," ") colIndex=row+offset ;Column Heading Cells1=objXL.Cells(1, colIndex) Cells1.Value=strValue ;Add special properties myfont = Cells1.Font myfont.FontStyle = "BOLD" myfont.size = 12 myfont.ColorIndex = 3 ; RED ;Row Heading Cells1=objXL.Cells(row+1, 1) Cells1.Value=strValue ;Add special properties myfont = Cells1.Font myfont.FontStyle = "BOLD" myfont.size = 12 myfont.ColorIndex = 3 ; RED :COLLOOP col=col+1 if col > 10 then goto ROWLOOP ;Sets values of cells strValue=row*col Cells1=objXL.Cells(row+offset, col+offset) Cells1.Value=strValue ;Add special properties myfont = Cells1.Font myfont.FontStyle = "BOLD" myfont.size = 10 goto COLLOOP :byebye ObjectClose(objXL) Message("WinBatch OLE Sample","Complete")
Article ID: W15256