serena_knight 1 Posted February 2 Share Posted February 2 i have a script with the following code /code Local $oVBS = ObjCreate("ScriptControl") $oVBS.language = "VBScript" Global Const $Nothing = $oVBS.eval("Nothing") $oVBS = $Nothing /endcode this code works on my computers and some other users but on some users the following error comes up line 44 (file "name of the script.au3...for security reasons cant supply the name) $oVBS.language = "VBScript" $oVBS^error error: variable muist be of type "object" note: users do have autoit installed Link to post Share on other sites
serena_knight 1 Posted February 2 Author Share Posted February 2 from dalehohm feb 23,2008 So, here is a way to make the Nothing value available in AutoIt: Local $oVBS = ObjCreate("ScriptControl") $oVBS.language = "VBScript" Global Const $Nothing = $oVBS.eval("Nothing") $oVBS = $Nothing $Nothing is then available to use anywhere in your script. so why does this not work for some users? Link to post Share on other sites
Developers Jos 2,852 Posted February 2 Developers Share Posted February 2 (edited) Look at example 2 in the helpfile as I would assume you should know by now how to test for success of a function! Edited February 2 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
mistersquirrle 59 Posted February 2 Share Posted February 2 I assume Jos is referring to example 2 of ObjCreate: https://www.autoitscript.com/autoit3/docs/functions/ObjCreate.htm That being said, things aren't working because ObjCreate("ScriptControl") is failing, and most likely it's failing on some computers and not others because of.... 64-bit! I tried your script (checking if ObjCreate actually worked) and it failed when run as default, which is in x64 mode. When I added #AutoIt3Wrapper_UseX64=n putting it into 32-bit code mode, it worked just fine. Give it a shot with adding #AutoIt3Wrapper_UseX64=n at the top of your code, and see if it works. Also as Jos mentioned, definitely add some If @error then... sections to your code to make sure that each step is working. I also recommend checking out the example 1 for https://www.autoitscript.com/autoit3/docs/functions/ObjEvent.htm as it allows you to replace the AutoIt error handler with your own, which can give you some more information on what errors you're getting. For me when running the code as x64, it said: "Class not registered" We ought not to misbehave, but we should look as though we could. Link to post Share on other sites
serena_knight 1 Posted February 3 Author Share Posted February 3 ty all for the help ...will give it a try Link to post Share on other sites
serena_knight 1 Posted February 13 Author Share Posted February 13 not working with the #AutoIt3Wrapper_UseX64=n Link to post Share on other sites
mistersquirrle 59 Posted February 14 Share Posted February 14 Any other information? Did you add error checking? Logging? Any messages? We ought not to misbehave, but we should look as though we could. Link to post Share on other sites
serena_knight 1 Posted February 14 Author Share Posted February 14 yes the same msg line 44 (file "name of the script.au3...for security reasons cant supply the name) $oVBS.language = "VBScript" $oVBS^error error: variable muist be of type "object" note: users do have autoit installed is it possible that scriptcontrol is not installed on the computer, how could you find out? Link to post Share on other sites
Developers Jos 2,852 Posted February 14 Developers Share Posted February 14 So did you do what i told you to do or did you simply ignore it? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
Trong 108 Posted February 16 Share Posted February 16 (edited) @serena_knight You need to check the objects to see if they initialize successfully or fail. Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF) Return SetError(1, 0, 0) EndFunc ;==>_ErrFunc Global $oScriptControl_IsReady = 0, $oVBS = ObjCreate("ScriptControl") If IsObj($oVBS) Then $oScriptControl_IsReady = 1 Global $iNothing If $oScriptControl_IsReady Then $oVBS.language = "vbscript" $iNothing = $oVBS.eval("Nothing") EndIf Global Const $Nothing = $iNothing ConsoleWrite("ScriptControl is available: " & $oScriptControl_IsReady & " > IsObj= " & IsObj($oVBS) & " > $Nothing= " & $Nothing & @CRLF) You need to add this Variable and function at the beginning of the script, it will skip and continue running the program without stopping the program and giving an object error! Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF) Return SetError(1,0,0) EndFunc ;==>_ErrFunc Edited February 16 by Trong make better Regards, Link to post Share on other sites
serena_knight 1 Posted February 17 Author Share Posted February 17 jos... i did what you said and it didnt work Link to post Share on other sites
Developers Jos 2,852 Posted February 17 Developers Share Posted February 17 Ok ... If all you can share is "doesn't work" then I guess we're done. SOLVE-SMART 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to post Share on other sites
serena_knight 1 Posted February 22 Author Share Posted February 22 ok,,,instead of using the code to get "nothing" how else could i get the "nothing" varible? Link to post Share on other sites
mistersquirrle 59 Posted February 22 Share Posted February 22 How about this, what is your goal? Do you need "ScriptControl"? What's the purpose of what you're trying to do? What are you going to do with this "Nothing" variable? As mentioned I can get the ScriptControl working, setting the language and getting "Nothing" all without errors, but I don't understand what the point is. You haven't provided any more information on your errors, we don't know what you actually want to do, so you're not going to get much help if you don't help us. We ought not to misbehave, but we should look as though we could. Link to post Share on other sites
serena_knight 1 Posted February 23 Author Share Posted February 23 (edited) ok i am working with an excel spreadsheet. i want to detect if specfic strings exist in a cell, like "empid" so i check in the script if "empid" has been retrived, if it is nothing then i msg and error. here is a real example $cells = $currentworksheet.cells if $cells = $nothing Then msgbox(0,"","problem with ref to cells") $oexcel.Workbooks(1).Close $oexcel.quit Exit EndIf Edited February 23 by serena_knight Link to post Share on other sites
mistersquirrle 59 Posted February 23 Share Posted February 23 I think that you'll need to include more of your script, it's best if you can provide a script that someone else here on the forum can run, without having to modify it (and while creating it you may yourself fix your problem by simplifying it). When you post code you could also use the code button to make it more readable: From what you've posted though is there a reason why you can't do one of these: ; I don't use the Excel UDF, but this seems like you're doing things the hard way $cells = $currentworksheet.cells ; I would suggest instead to use the Excel UDF, and do this: Local $sResult = _Excel_RangeRead($oWorkbook, Default, "A1") ; Read data from a single cell (string for single cell, array for range) ; Choose one of these: ;===================== If $sResult = '' Then DoNothing() ;===================== If $sResult <> '' Then DoNothing() ;===================== If StringLen($sResult) >= 1 Then DoNothing() ;===================== Switch $sResult Case 'Value1' DoSomething() Case Else DoNothing() EndSwitch ;===================== $nothing = '' If $sResult == $nothing Then DoNothing() ;===================== Also, I recommend that if you're working with Excel, you at least try out the Excel UDF first, instead of whatever you're doing: https://www.autoitscript.com/autoit3/docs/libfunctions/Excel Management.htm https://www.autoitscript.com/wiki/Excel_UDF We ought not to misbehave, but we should look as though we could. Link to post Share on other sites
serena_knight 1 Posted March 3 Author Share Posted March 3 ty all for your help..... this problem has been resolved..the user reinstalled autoit on their computer . this solved the problem Link to post Share on other sites
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