Jump to content

word doc probs


subina
 Share

Recommended Posts

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

  • Moderators

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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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)

 

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

No, I mean this thread:

 

Edited 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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...