Sign in to follow this  
Followers 0
ClayR

Script won't run

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by MPH

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0