ResNullius Posted March 14, 2009 Share Posted March 14, 2009 (edited) Office 2003 on XP Pro SP3The following vbs script functions as expected and returns the Author info for the excel file:Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open("C:\Test.xls") Wscript.Echo objWorkbook.BuiltinDocumentProperties("Author") objExcel.quitHowever, the following AutoIt script returns an empty string.$oExcel = ObjCreate("Excel.Application") $oWorkbook = $oExcel.Workbooks.Open("C:\Book1.xls") MsgBox(0,"",$oWorkbook.BuiltinDocumentProperties("Author")) $oExcel.quitIn fact, the value for any of the BuiltinDocumentProperties returned by the AutoIt script is empty.What, if anything, am I doing wrong? Edit: changed subject to [solved] Edited March 15, 2009 by ResNullius Link to comment Share on other sites More sharing options...
ChrisL Posted March 14, 2009 Share Posted March 14, 2009 (edited) Possibly not doing it the correct way but this seemed to work for me $oExcel = ObjCreate("Excel.Application") $oWorkbook = $oExcel.Workbooks.Open(@scriptDir & "\test.xls") $oProperties = $oWorkbook.BuiltinDocumentProperties() For $items in $oProperties If $items.Name = "Author" then MsgBox(0,"Author", $items.Value ) Next $oExcel.Close $oExcel.quit Edited March 14, 2009 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted March 14, 2009 Share Posted March 14, 2009 (edited) You can get quite a lot of information out of it this way, I had to use the error handler in it because some items failed maybe because they need a different way of getting the data or .Value shouldbe an array maybe? $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); error handler $oExcel = ObjCreate("Excel.Application") $oWorkbook = $oExcel.Workbooks.Open(@scriptDir & "\test.xls") $oProperties = $oWorkbook.BuiltinDocumentProperties() For $items in $oProperties ConsoleWrite($items.Name & " = " & $items.Value & @crlf) Next $oExcel.Close $oExcel.quit Func MyErrFunc() $g_eventerror = 1; something to check for when this function returns Endfunc Edited March 14, 2009 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ResNullius Posted March 15, 2009 Author Share Posted March 15, 2009 (edited) Thanks ChrisL, works a treat.Still, I wonder what the difference is in the way AutoIt deals with the collection... Edit: Re: the errors http://msdn.microsoft.com/en-us/library/mi...rty(VS.80).aspxIf a given application doesn't define a value for one of the built-in document properties, returning the Value property for that document property causes an error. Edited March 15, 2009 by ResNullius Link to comment Share on other sites More sharing options...
ResNullius Posted March 15, 2009 Author Share Posted March 15, 2009 And here is how to modify the AutoIt script in my original post to work: $oExcel = ObjCreate("Excel.Application") $oWorkbook = $oExcel.Workbooks.Open("C:\Book1.xls") MsgBox(0,"",$oWorkbook.BuiltinDocumentProperties("Author").Value) $oExcel.quit Link to comment Share on other sites More sharing options...
ChrisL Posted March 15, 2009 Share Posted March 15, 2009 And here is how to modify the AutoIt script in my original post to work: $oExcel = ObjCreate("Excel.Application") $oWorkbook = $oExcel.Workbooks.Open("C:\Book1.xls") MsgBox(0,"",$oWorkbook.BuiltinDocumentProperties("Author").Value) $oExcel.quit Cool... I really didn't know what I was doing I just buggered about with it until I got some data out [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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