lgodfrey Posted October 15, 2005 Share Posted October 15, 2005 I noticed that under Tools/References in Excel VBA window, AutoItX3 1.0 Time Library is listed. My understanding is that checking a reference here is supposed to allow you to reference functions or definitions in the module checked. I tried checking this and using AUtoITX3 method without a AutoITX3 object modifier, but got an error msg. So exactly what does checking this reference do? I'm, Lovin' IT, X Link to comment Share on other sites More sharing options...
zfisherdrums Posted October 21, 2005 Share Posted October 21, 2005 (edited) Hey lgodfrey (nice avatar!) You are correct in that checking the box does add a reference to AutoIt into your project, but you need to create and instantiate an AutoItX3 object. Try placing this code inside a code module (i.e. NOT a Sheet or 'ThisWorkbook'): Public Sub TestingAutoIT() Dim autoItObj As AutoItX3 Set autoItObj = New AutoItX3 With autoItObj .WinActivate ("A Window Name") End With Set autoItObj = Nothing End Sub VBA will now recognize the methods and properties when you reference autoItObj within the TestingAutoIT sub. Functions can be easily accesed within the "With...End With" statements by typing a period and letting intellisense do all the looking up for you. Now if it could just do my taxes... One caveat I've found when using AutoIt from VBA: Win functions can get a little messy. I don't know if it's the way VBA is compiled, but it seems as though focus can sometimes get passed BACK to VBA when the script is sending keystrokes etc. If anyone knows precisely why this occurs, I'd love to know! I've been able to work around it by ensuring that winActivate is called after any conditonal logic and before the key commands are sent. I hope this helps you. Edited October 21, 2005 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
lgodfrey Posted October 24, 2005 Author Share Posted October 24, 2005 Hey lgodfrey (nice avatar!)You are correct in that checking the box does add a reference to AutoIt into your project, but you need to create and instantiate an AutoItX3 object.Try placing this code inside a code module (i.e. NOT a Sheet or 'ThisWorkbook'):Public Sub TestingAutoIT() Dim autoItObj As AutoItX3 Set autoItObj = New AutoItX3 With autoItObj .WinActivate ("A Window Name") End With Set autoItObj = NothingEnd SubVBA will now recognize the methods and properties when you reference autoItObj within the TestingAutoIT sub. Functions can be easily accesed within the "With...End With" statements by typing a period and letting intellisense do all the looking up for you. Now if it could just do my taxes...One caveat I've found when using AutoIt from VBA: Win functions can get a little messy. I don't know if it's the way VBA is compiled, but it seems as though focus can sometimes get passed BACK to VBA when the script is sending keystrokes etc. If anyone knows precisely why this occurs, I'd love to know! I've been able to work around it by ensuring that winActivate is called after any conditonal logic and before the key commands are sent.I hope this helps you.Thanks for the reply!I just usePublic oAIX As Object 'in my declarations moduleSet oAIX = CreateObject("AutoItX3.Control") 'in my variable definition module (I have pretty big project, so I keep initial variable definitions and other initializations in their own module)I do not need the reference to AutoITX for this to work, I was just wondering why it is even there if it doesn't seem to do anything or even be needed!RegardsLarry I'm, Lovin' IT, X Link to comment Share on other sites More sharing options...
doudou Posted November 24, 2005 Share Posted November 24, 2005 I do not need the reference to AutoITX for this to work, I was just wondering why it is even there if it doesn't seem to do anything or even be needed!lgodfrey, when you do thing like this: Dim oAIX as Object Set oAIX = CreateObject("AutoItX3.Control") it's called 'late binding', in this case your COM system takes all information about the library from Windows registry at time your program runs, so your project doesn't need the reference. On the other hand this code: Dim autoItObj As AutoItX3 Set autoItObj = New AutoItX3 so-called 'early binding', that means all references are resolved at compile time, that's why you must introduce it in your project. This method is more reliable by the way, as possible errors are detected by the compiler and not by the customer UDFS & Apps: Spoiler DDEML.au3 - DDE Client + ServerLocalization.au3 - localize your scriptsTLI.au3 - type information on COM objects (TLBINF emulation)TLBAutoEnum.au3 - auto-import of COM constants (enums)AU3Automation - export AU3 scripts via COM interfacesTypeLibInspector - OleView was yesterday Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE Link to comment Share on other sites More sharing options...
RenanTakara Posted June 30, 2016 Share Posted June 30, 2016 Hi guys, I was using autoit with VBA in another machine, but now I changed it, and when I'm declaring "Set autoItObj = New AutoItX3" I get the error: Runtime Error 429 - ActiveX Component Can't Create Object Someone knows whats happening? I'm using Excel 2013. Thanks! 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