subina

word doc probs

8 posts in this topic

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

 

 

Share this post


Link to post
Share on other sites



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.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

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 2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-05-09 - Version 1.2.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 

#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)

 

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-05-09 - Version 1.2.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

No, I mean this thread:

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-05-09 - Version 1.2.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

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