subina Posted September 16, 2016 Share Posted September 16, 2016 i am trying to get information off a word document. i can access the document but am having problems i had some old code that used word object programming but that dont seem to work any more with i use for example "with $owordapp.documents.application.selection.find " which gives me only object-type variables allowed in a with statement. this used to work the $owordapp object is from $owordapp = _word_docattach($oword, $ftitle, "filename") which works after i find the string i am looking for i need to move about the page with statements like $odoc.application.selection.moveright($wdcell,1) $odoc.application.selecton.expand($wdline) $secin = $odoc.application.selection.text autoit does not seem to have provisions to do this kind of thing Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 16, 2016 Moderators Share Posted September 16, 2016 Can you please post the entire script so we can see what you're doing and duplicate? It is a bit difficult to assist based on a couple disparate lines of code, especially when you have unknown variables in those lines. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
aiter Posted September 16, 2016 Share Posted September 16, 2016 You have to lookup the word objects on the web. See https://msdn.microsoft.com/en-us/library/ff841702(v=office.14).aspx Say you have opened the document to variable $odoc The statements you have typed should work exactly as you typed them. You can also open up Word.au3 (UDF) and see how its done. Link to comment Share on other sites More sharing options...
water Posted September 16, 2016 Share Posted September 16, 2016 If the old script used the old Word UDF then a lot has changed starting with AutoIt 3.3.10.0. Details can be found here: https://www.autoitscript.com/autoit3/docs/script_breaking_changes_word_udf.htm My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
subina Posted September 16, 2016 Author Share Posted September 16, 2016 #include <word.au3> $wdline = 5 $wdcell = 12 ; find the text then get the text following the found text $objword = objcreate("word.application $wordfile = "c:\userid.test.docx" $ftitle = "test.docx" $oword = _word_create() $owordapp = _word_docattach($oword, $ftitle, "filename") $odoc = _word_docopen($word,$wordfile) $searcharg1 = "test this" with $owordapp.documents.application.selections.find .clearformatting .text = $searcharg1 .forward= true .wrap= 1 .format = false endwith $owordapp.documents.application.selection.find.execute $odoc.application.selection.moveright($wdcell, 1) $odoc.application.selection.expand.($wdline) $secin = $doc.application.selection.text msgbox(0,"",$secin) Link to comment Share on other sites More sharing options...
water Posted September 16, 2016 Share Posted September 16, 2016 (edited) Did you syntax check your script? Here it returns a lot of errors. BTW: Could you please use code tags (the "<>" icon in the editor)? This formats your code and makes it easier to read Edited September 16, 2016 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
subina Posted September 16, 2016 Author Share Posted September 16, 2016 sorry its been a while.. did you mean <> before and after the code? also sorry bout the script, i am unable to copy and paste so i had to retype the script. also i noticed that $wdword etc does not have to be stated , i removed those and i in the with statement i used, $oword insTEAD of $OWORDAPP and that got by the error i got,, i also think there is a problem with the form as it may be password protected so i will have to work around, thanks so much for your attention, i will be back after trying some things Link to comment Share on other sites More sharing options...
water Posted September 16, 2016 Share Posted September 16, 2016 (edited) No, I mean this thread: Edited September 16, 2016 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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