jnash67 Posted September 19, 2010 Share Posted September 19, 2010 Can someone please explain these confusing results with regard to COM object types when creating an Excel object for embedding into an AutoIt GUI (as detailed in http://www.autoitscript.com/forum/index.php?showtopic=31963) When loading an excel object from a file with ObjGet, ObjName returns _Workbook $oExcelDoc = ObjGet("C:\temp\book1.xls") MsgBox(0, "$oExcelDoc", ObjName($oExcelDoc)) When creating an excel object with ObjCreate or with _ExcelBookNew (which just uses ObjCreate), ObjName returns _Application $oExcelDoc = ObjCreate("Excel.Application") MsgBox(0, "$oExcelDoc", ObjName($oExcelDoc)) $oExcel = _ExcelBookNew(1) MsgBox(0, "$oExcelDoc", ObjName($oExcelDoc)) When getting the activeworkbook or the activesheet from _Application object, ObjName returns nothing $oExcelDoc = ObjCreate("Excel.Application") $oExcelBook = $oExcelDoc.ActiveWorkbook $oExcelSheet = $oExcelDoc.activesheet MsgBox(0, "$oExcelBook", ObjName($oExcelBook)) MsgBox(0, "$oExcelSheet", ObjName($oExcelSheet)) When using these objects with GUICtrlCreateObj, only the object that is identified by ObjName as _Workbook works (i.e. doesn't generate a COM error). How can I obtain a _Workbook object without opening a file? What explains these results? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now