lijrobert Posted July 24, 2014 Share Posted July 24, 2014 (edited) So I started working on a script to parse so data from and .xls file, but I've reached a little error. After copying a lot of the code from some of the example scripts, I'm getting this error Variable must be of type "Object".: $wfData = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 1) $wfData = _Excel_RangeRead($oWorkbook, Default, $oWorkbook^ ERROR Here is my code: #include <Excel.au3> #include <Array.au3> #include "Zip.au3" Const $filePath = @ScriptDir & "\Workfiles.xls" Const $captPath = @ScriptDir & "\IECapt.exe" $startScriptTest = FileExists($filePath) $startScriptTest = FileExists($captPath) if Not $startScriptTest Then MsgBox(0,"Error","You do not have all the required files in the directory with the exectuable. Please read the readme") EndIf $oAppl = _Excel_Open() $oWorkbook = _Excel_BookOpen($oAppl, $filePath) $wfData = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 1) Sorry if this is something I'm missing in the documentation, but I've read it several times with no improvement Edited July 24, 2014 by lijrobert Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 24, 2014 Moderators Share Posted July 24, 2014 Hi, lijrobert, welcome to the forum. The code you have works for me, as I can see the contents of column A returned (remember it is returned as an array). I don't have your Zip.au3, or your IECapt.exe, so I stripped your script down a bit, but this works fine: #include <Array.au3> #include <Excel.au3> #include <Array.au3> ;#include "Zip.au3" Const $filePath = @ScriptDir & "\Workfiles.xls" ;Const $captPath = @ScriptDir & "\IECapt.exe" $startScriptTest = FileExists($filePath) ;$startScriptTest = FileExists($captPath) if Not $startScriptTest Then MsgBox(0,"Error","You do not have all the required files in the directory with the exectuable. Please read the readme") $oAppl = _Excel_Open() $oWorkbook = _Excel_BookOpen($oAppl, $filePath) $wfData = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 1) _ArrayDisplay($wfData) Just out of curiosity, what version of AutoIt are you using? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
lijrobert Posted July 24, 2014 Author Share Posted July 24, 2014 Hi, lijrobert, welcome to the forum. The code you have works for me, as I can see the contents of column A returned (remember it is returned as an array). I don't have your Zip.au3, or your IECapt.exe, so I stripped your script down a bit, but this works fine: #include <Array.au3> #include <Excel.au3> #include <Array.au3> ;#include "Zip.au3" Const $filePath = @ScriptDir & "\Workfiles.xls" ;Const $captPath = @ScriptDir & "\IECapt.exe" $startScriptTest = FileExists($filePath) ;$startScriptTest = FileExists($captPath) if Not $startScriptTest Then MsgBox(0,"Error","You do not have all the required files in the directory with the exectuable. Please read the readme") $oAppl = _Excel_Open() $oWorkbook = _Excel_BookOpen($oAppl, $filePath) $wfData = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 1) _ArrayDisplay($wfData) Just out of curiosity, what version of AutoIt are you using? I'm using v3.3.12.0. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 24, 2014 Moderators Share Posted July 24, 2014 And the workbook is opening successfully for you, if you comment out the $wfData line? I am unable to get your script to fail. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Solution lijrobert Posted July 24, 2014 Author Solution Share Posted July 24, 2014 Just realized I don't have excel installed. Guess I need that Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 24, 2014 Moderators Share Posted July 24, 2014 Glad you got it resolved "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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