Yeah, it's a scope issue. TestComplete is not aware of the Excel variable. You need to move the declaration of the variable outside of the scope of the function. You would then, also, need to wrap that variable with a Get and Set method if you want to be able to access it from within your automation. I would also rename your function from "excel" to something else like "ChangeExcelState". The end result would be that you would have a runtime object with a read/write property called "Excel" and a function called ChangeExcelState. Your code in your automation would then read:
global.ChangeExcelState('open', 'F:/Spreadsheets/mySpreadsheet.xlsx', 'Worksheet_5') ;
global.Excel.Cells(10,15).Interior.ColorIndex = 0 ; // Set Cell background color to WHITE
global.ChangeExcelState('close') ;
Take a look at this article:
http://smartbear.com/support/viewarticle/11960/Specifically, follow the link to the section on creating object properties.