Lights_On

_Word_DocFind has no @error

6 posts in this topic

Hi all,

The below string works if the searched term exists, however if it does not - I don't get an '@error' or '@extended' - the scrip appears to just keep running?

Local $result = _Word_DocFind($oDoc, $ComString, 0, Default, True, False, True, True)

I can get errors with other combination of parameters but not with the above however only the above does what i need.  It seems to be the combination of: 

$bMatchWildcards

 

$bMatchWholeWord

that is does not like if a term can not be matched, as changing one of these allows for an error to be found but then also no matches are found.

 

I seek to create an 'if' statement using the above string so when it finds a match is does one set of things, and if no match is found then it does something else.  With out an error being generated i can only do something when a match is found and when a match is not found the script just hangs as does not set and error so as such does not move on?

 

Scratching my head on this one.

 

Thank you in advance. 

V3.3.14.2

Share this post


Link to post
Share on other sites



A reproducer script would be fine. Means:
Can you post a word document plus a small script that reproduces your problem?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water,

Thank you for your quick reply.

In creating the test script and docs I found it worked – sort of.  Let me explain before I post further code etc.  When testing basic docs all works as expected.  When testing on my real environment it still failed as above.

The difference between the docs is the use of tables. If I have docs with tables it hangs.  If I don’t it does not.

I see there is _Word_DocTableRead so perhaps I use this in some way.  Initial thoughts / questions.

Aim:

  • To search a word document for a sting using the above find solution.

Issues:

Table’s cause hangs.

  • Should I detect tables and or search them separately – if so how

  • Should convert the docs to plain text and then search plain text documents?

  • Would I be better reading the entire doc to an array and then search the array?

With a little direction as to which route is likely best I can go and do some more reading etc.

Thank you in advance.

Share this post


Link to post
Share on other sites

Then please post a word document with tables and the reproducer script so I can play with it :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Good morning Water,

 

Thank you for your (as always) time and helpful support with fast replies.

 

I have since changed the way I was scripting as, in fact, in the long run it suited my purpose better.  I ended up opening the work document, saving it as a .txt document - then reading this into an array.  This allowed for me to do what i needed to with far greater ease and speed.  As with many projects its not until one starts digging further that realisation of the best way to do things becomes apparent.

 

The issue was still with tables however I believe it was my need to read in the data in a better way that was more relevant.  Not an issue with the UDF.

 

Many thanks as always.

 

 

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.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
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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

  • Similar Content

    • ahha
      By ahha
      Okay I've hacked down a large program to illustrate the problem I'm having.
      I'm using the built-in Word UDF (which is great) and am finding a range and then copying it to the clipboard and sticking it in an array for viewing.
      Then extending the range and again copying it to a clipboard and sticking it into the array.
      It seems to drop the ranges randomly.  I can't figure out what I'm doing wrong (or if there's a better way to get a range into a variable).
      Run the program with the test file and you'll see entries being dropped (put test file in same directory as the program).
      Any pointers or help much appreciated.
      Hacked down program for testing Range extend and copy v3c.au3
      Test for Range Copy v1a.docx