ClayR Posted September 20, 2010 Share Posted September 20, 2010 Run("M:\The Park\Barossa @ The Park\Leasing Workbench\Workbench live Barossa 6-17-10.xls") Sleep(5000) Send("{ENTER}") Sleep(2000) WinClose("Microsoft Excel") Send("{ENTER}") Super simple script...but all it does is just open instance after instance, and never actually does anything listed above. Thinking it was perhaps the file (and not the code), I copied this into a working script and removed all the coding except theses lines above with the same result. Link to comment Share on other sites More sharing options...
Bert Posted September 20, 2010 Share Posted September 20, 2010 (edited) Look at this example. (from the helpfile, _ExcelBookOpen ) #include <Excel.au3> $sFilePath1 = @ScriptDir & "\Test1.xls" ;This file should already exist $oExcel = _ExcelBookOpen($sFilePath1) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist!") Exit EndIf Edited September 20, 2010 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 20, 2010 Share Posted September 20, 2010 You are starting the script by double-clicking the file in Explorer and as Run() fails you have the script start itself when it presses Enter. You really should try the Excel UDF instead, as MPH said. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
seandisanti Posted September 20, 2010 Share Posted September 20, 2010 You really should try the Excel UDF instead, as MPH said. Or the COM objects of excel are very well documented and pretty easy to use... $oEX = ObjCreate("","excel.Application") $oWb = $oEX.Workbooks.Add("Whatever.xls") $oWb.Activesheet.range("a1").formula = "I'm Cell A1!") sleep(1000) $oWb.Activesheet.range("a1").formula = "but i'm going away and taking my row with me") $oAS = $oWb.Activesheet;could have done this earlier but just showing how easy it is to do different things $oAS.Rows("1:1").delete MsgBox(0,"finished","playtime is over") $oEX.Quit Link to comment Share on other sites More sharing options...
ClayR Posted September 20, 2010 Author Share Posted September 20, 2010 Thanks guys for the prompt help- I will play around with these options. Or the COM objects of excel are very well documented and pretty easy to use... $oEX = ObjCreate("","excel.Application") $oWb = $oEX.Workbooks.Add("Whatever.xls") $oWb.Activesheet.range("a1").formula = "I'm Cell A1!") sleep(1000) $oWb.Activesheet.range("a1").formula = "but i'm going away and taking my row with me") $oAS = $oWb.Activesheet;could have done this earlier but just showing how easy it is to do different things $oAS.Rows("1:1").delete MsgBox(0,"finished","playtime is over") $oEX.Quit Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 20, 2010 Share Posted September 20, 2010 Or the COM objects of excel are very well documented and pretty easy to use...The udf IS com-objects. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
seandisanti Posted September 20, 2010 Share Posted September 20, 2010 The udf IS com-objects.No, the UDF is a collection of user defined functions that interact with the COM objects to allow an "autoit feel". That's why you call _ExcelBookOpen($sFilePath1) instead of $oEX.Workbooks.Add($aFilePath1). Personally i'd rather interact with the objects DIRECTLY because the method names tend to be shorter than the function names, and i don't think that there are FUNCTIONS in the UDF for every property or method of every office object. So rather than hunting through a udf to find the function to do what i want, and see how the UDF writer wants me to call it, i can look in the object browser in VBA (F2) and see every member that can be accessed explicitly. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 20, 2010 Share Posted September 20, 2010 We are talking about a user that can't even figure out how Run works. You're just over-complicating things. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
trancexx Posted September 20, 2010 Share Posted September 20, 2010 We are talking about a user that can't even figure out how Run works. You're just over-complicating things.Nevertheless.I agree with cameronsdad. ♡♡♡ . eMyvnE 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