AvidLearner Posted March 19, 2009 Share Posted March 19, 2009 When I run my script, it gives an error saying variable must be of type object in the _wordattach code line CODE#Include<file.au3> #include<string.au3> #include<word.au3> #include <WindowsConstants.au3> AutoItSetOption( "trayiconhide",1 ) AutoItSetOption( "wintitlematchmode",2 ) AutoItSetOption( "sendkeydelay",1 ) AutoItSetOption( "WinTextMatchMode",1 ) WinwaitActive( "- Microsoft Word" ) $title1 = WinGetTitle( "Microsoft Word" ) $docname = StringTrimRight( $title1 , 17 ) $result = StringInStr( $docname , "compatibility" ) If $result = 0 Then Else $docname = StringTrimRight( $docname , 21 ) EndIf If $result = 0 Then $docname = _StringInsert( ".docx",$docname,-5 ) Else $docname = _StringInsert( ".doc",$docname,-4 ) EndIf $oWordApp = _WordAttach($docname, "FileName") $oDoc = _WordDocGetCollection ($oWordApp, -1) For $oDoc in $oDoc If Stringinstr($oDoc.FullName, $docname) Then $oPath = $oDoc.FullName Next MsgBox(0,$oPath,"") Link to comment Share on other sites More sharing options...
AvidLearner Posted March 19, 2009 Author Share Posted March 19, 2009 Pls do help me .... Thanks in advance... Link to comment Share on other sites More sharing options...
ResNullius Posted March 19, 2009 Share Posted March 19, 2009 Running the script from SciTE, the output conole gives this:--> Word.au3 Warning from function _WordAttach, $_WordStatus_NoMatch--> Word.au3 Error from function _WordDocGetCollection, $_WordStatus_InvalidDataTypeC:\Temp\temp-35.au3 (28) : ==> Variable must be of type "Object".:For $oDoc in $oDocFor $oDoc in $oDoc^ ERRORNote the warnings/errors from word.au3.There's something wrong with your code in those lines... Link to comment Share on other sites More sharing options...
Spiff59 Posted March 19, 2009 Share Posted March 19, 2009 Play with this... #Include<file.au3> #include<string.au3> #include<word.au3> #include <WindowsConstants.au3> AutoItSetOption( "trayiconhide",1 ) AutoItSetOption( "wintitlematchmode",2 ) AutoItSetOption( "sendkeydelay",1 ) AutoItSetOption( "WinTextMatchMode",1 ) WinwaitActive( "- Microsoft Word" ) $title1 = WinGetTitle( "Microsoft Word" ) $docname = StringTrimRight( $title1 , 17 ) $result = StringInStr( $docname , "compatibility" ) If $result = 0 Then Else $docname = StringTrimRight( $docname , 21 ) EndIf ;If $result = 0 Then ;$docname = _StringInsert( ".docx",$docname,-5 ) ;Else ;$docname = _StringInsert( ".doc",$docname,-4 ) ;EndIf MsgBox(0,"",$docname) $oWordApp = _WordAttach($docname, "FileName") $oDoc = _WordDocGetCollection ($oWordApp, -1) For $oDoc in $oDoc If Stringinstr($oDoc.FullName, $docname) Then $oPath = $oDoc.FullName Next MsgBox(0,$oPath,"") Link to comment Share on other sites More sharing options...
AvidLearner Posted March 19, 2009 Author Share Posted March 19, 2009 Play with this... #Include<file.au3> #include<string.au3> #include<word.au3> #include <WindowsConstants.au3> AutoItSetOption( "trayiconhide",1 ) AutoItSetOption( "wintitlematchmode",2 ) AutoItSetOption( "sendkeydelay",1 ) AutoItSetOption( "WinTextMatchMode",1 ) WinwaitActive( "- Microsoft Word" ) $title1 = WinGetTitle( "Microsoft Word" ) $docname = StringTrimRight( $title1 , 17 ) $result = StringInStr( $docname , "compatibility" ) If $result = 0 Then Else $docname = StringTrimRight( $docname , 21 ) EndIf ;If $result = 0 Then ;$docname = _StringInsert( ".docx",$docname,-5 ) ;Else ;$docname = _StringInsert( ".doc",$docname,-4 ) ;EndIf MsgBox(0,"",$docname) $oWordApp = _WordAttach($docname, "FileName") $oDoc = _WordDocGetCollection ($oWordApp, -1) For $oDoc in $oDoc If Stringinstr($oDoc.FullName, $docname) Then $oPath = $oDoc.FullName Next MsgBox(0,$oPath,"") Got the error again.... Link to comment Share on other sites More sharing options...
AvidLearner Posted March 19, 2009 Author Share Posted March 19, 2009 (edited) When exactly does this error appear..?? --> Variable must be of type "Object". Edited March 19, 2009 by AvidLearner Link to comment Share on other sites More sharing options...
Spiff59 Posted March 19, 2009 Share Posted March 19, 2009 Once I commented out your code that appended a suffix (file entension) to the document title, it found "Document1" and ran through the end of the script without error for me. Link to comment Share on other sites More sharing options...
AvidLearner Posted March 19, 2009 Author Share Posted March 19, 2009 Once I commented out your code that appended a suffix (file entension) to the document title, it found "Document1" and ran through the end of the script without error for me.Yeah I tried it,,,, but getting the error & terminating the program....I dunno what to do... Link to comment Share on other sites More sharing options...
AvidLearner Posted March 19, 2009 Author Share Posted March 19, 2009 Try to run the code given below,,, it definitely will show an error saying " variable must be of type "object" "... CODE#Include<file.au3> #include<string.au3> #include<word.au3> #include <WindowsConstants.au3> AutoItSetOption( "trayiconhide",1 ) AutoItSetOption( "wintitlematchmode",2 ) AutoItSetOption( "sendkeydelay",1 ) AutoItSetOption( "WinTextMatchMode",1 ) WinwaitActive( "- Microsoft Word" ) $title1 = WinGetTitle( "Microsoft Word" ) $docname = StringTrimRight( $title1 , 17 ) $result = StringInStr( $docname , "compatibility" ) If $result = 0 Then Else $docname = StringTrimRight( $docname , 21 ) EndIf $oWordApp = _WordAttach($docname, "FileName") $oDoc = _WordDocGetCollection ($oWordApp, -1) For $oDoc in $oDoc If Stringinstr($oDoc.FullName, $docname) Then $oPath = $oDoc.FullName Next MsgBox(0,$oPath,"") Link to comment Share on other sites More sharing options...
Spiff59 Posted March 20, 2009 Share Posted March 20, 2009 If I open up an instance of Word, that example runs fine for me. You do have Office installed, rather than just wordpad? Link to comment Share on other sites More sharing options...
AvidLearner Posted March 22, 2009 Author Share Posted March 22, 2009 If I open up an instance of Word, that example runs fine for me.You do have Office installed, rather than just wordpad?Yeah I use office 2007 Link to comment Share on other sites More sharing options...
DaleHohm Posted March 22, 2009 Share Posted March 22, 2009 Please study the messages you are getting in the SciTe console carefully. If you want help here, show the full messages you are getting (as ResNullius did). Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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