OLE and Excel BuiltinDocumentProperties
Keywords: OLE and Excel BuiltinDocumentProperties
Question:
I am building OLE code to capture the BuiltinDocumentProperties from Windows Applications. I have Microsoft Word working well, but can not figure out how to make it work with Excel. Please look at the code below and tell me where my obvious error is.debug(@on) objXL = ObjectOpen("Excel.Application") objXL.Visible = @true objXL.UserControl = @FALSE XLWkBook = objXL.Workbooks XLWkBook.Open("C:\dancerprodata\Archive\test\jatest1.xls") objWkSheet = objXL.Worksheets(1) objWkSheet.Activate for i = 1 to 5 ; The following statement causes: 3245 Ole Object: Method name too long bidp = XLWkBook.BuiltinDocumentProperties.Item(i) propval = bidp.value len = StrLen(propval) message("Prop %i% length in %docname% is %len%", "[%propval%]") next ObjectClose(objWkSheet) XLWkBook.Close() ObjectClose(XLWkBook) ObjectClose(objXL) ; The following statements works in Word ;wsas = WDOC.activedocument ; for i = 1 to 5 ; bidp = wsas.BuiltinDocumentProperties.Item(i) ;....Answer:
This will do it...;Define .XLS file and sheetname to activate EXF = "C:\Program Files\Microsoft Office\Office\Library\COMMON.XLS" ;Open Excel objXL= ObjectOpen("Excel.Application") objXL.Visible = @TRUE ;Open XLS file MyWorkbook = objXL.workbooks MWO = MyWorkbook.open(EXF) ;Get active workbook object AWB = objXL.activeworkbook for i = 1 to 15 bidp = AWB.BuiltinDocumentProperties(i) propval = bidp.value len = StrLen(propval) message("Prop %i% length in %docname% is %len%", "[%propval%]") next ObjectClose(objXL)
Article ID: W14930