Jump to content
Sign in to follow this  
TheReveller

Some basic about Object creation

Recommended Posts

TheReveller

Hi,

I just wanted to know something when you create an object.

I have this :

$oExcel = _ExcelBookNew(); Opens Excel

$oExcel.Visible = 0

And then I run a huge script using Excel's VBA and I end with this :

$oExcel.Visible = 1

WinSetState("[CLASS:XLMAIN]", "", @SW_MAXIMIZE)

But creating $oExcel will necessairly wait for the object to be created before sending my VBA commands, right ? I mean, I don't have to do this :

$oExcel = _ExcelBookNew(); Opens Excel

If WinWaitActive("[CLASS:XLMAIN]", "", 5) Then

$oExcel.Visible = 0

[Huge script...]

$oExcel.Visible = 1

WinSetState("[CLASS:XLMAIN]", "", @SW_MAXIMIZE)

If I consider that Excel will open someday and the user has Excel.

Comments and advices ?

Thanks,

TheReveller

Share this post


Link to post
Share on other sites
PsaltyDS

Hi,

I just wanted to know something when you create an object.

I have this :

$oExcel = _ExcelBookNew(); Opens Excel

$oExcel.Visible = 0

And then I run a huge script using Excel's VBA and I end with this :

$oExcel.Visible = 1

WinSetState("[CLASS:XLMAIN]", "", @SW_MAXIMIZE)

But creating $oExcel will necessairly wait for the object to be created before sending my VBA commands, right ? I mean, I don't have to do this :

$oExcel = _ExcelBookNew(); Opens Excel

If WinWaitActive("[CLASS:XLMAIN]", "", 5) Then

$oExcel.Visible = 0

[Huge script...]

$oExcel.Visible = 1

WinSetState("[CLASS:XLMAIN]", "", @SW_MAXIMIZE)

If I consider that Excel will open someday and the user has Excel.

Comments and advices ?

Thanks,

TheReveller

What was the question in there? ^_^

You want to perform VBA-like functions on excel without waiting for... what?

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
TheReveller

When you are a Excel object for example, do you have to wait for the Excel to open with a WinWait before performing a Excel VBA action through AutoIt or will the Excel VBA action wait by itself for the Excel object to be complete created ?

I mean, that's like I have a script that opens everything that is in a treeview and with a Sleep(1) before going to next, the computer will wait for the folder in the treeview to be done to open before trying to go to next item (but that doesn't seem to work on windows explore, anyways)

I don't know how to say what I mean...

Share this post


Link to post
Share on other sites
PsaltyDS

When you are a Excel object for example, do you have to wait for the Excel to open with a WinWait before performing a Excel VBA action through AutoIt or will the Excel VBA action wait by itself for the Excel object to be complete created ?

I mean, that's like I have a script that opens everything that is in a treeview and with a Sleep(1) before going to next, the computer will wait for the folder in the treeview to be done to open before trying to go to next item (but that doesn't seem to work on windows explore, anyways)

I don't know how to say what I mean...

I believe the COM methods in Excel don't return until they have completed their action. I have never bothered inserting any wait between opening a workbook and reading/writing cells, for example, and haven't had any issues with it. If you examine the code inside Excel.au3, you will find no sleeps to waiting for .open, .select, etc. to complete before continuing. Many people use that UDF and don't seem to have issues.

This would not be hard to test for you specific case. Write a test script that performs your desired action 100 times in a loop and see if there are any issues.

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
TheReveller

Ok, thanks, that answers my question.

For your Excel example, well I've already had some problems with _ExcelSheetMove right after a _ExcelSheetAddNew... And I also had to add a sleep in some cases like this one for example :

_ExcelSheetActivate($oExcel, "("&$i+1&")")

Sleep(100)

$oExcel.Columns("A:AX").EntireColumn.AutoFit

$oExcel.Cells.Select

Sleep(100)

$oExcel.Selection.AutoFilter

And there is still that problem with treeviews where I open all the tree with a Sleep(1) before next item which works in all treeviews I tested, even one treeview retrieving information on next item in a database (code will wait to load the database items because of the sleep), but that won't work in the explore treeview, folders are bypassed instead of being opened unless I increase the sleep to something like Sleep(500)...

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  

×