Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Automation - Finding strings
Message
 
À
10/08/2001 12:30:20
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00541649
Message ID:
00542464
Vues:
22
>>Hi, I need to scan all Word documents from a hard disk, trying to find some kind of documents. I know that these documents have 2 strings, one above the other, like:
>>
>>First string in line 14
>>Second string in line 15
>>
>>These strings can be found in another sections of the document, but in just one case (the one that I need, one above the other) they identify the documents that I´m looking for.
>>I know how to search the strings, but I don´t know how to retrieve the lines where they were found. Any ideas?
>>
>>Regards,
>
>Jose,
>To get lines from word pagination needs to be enabled and current view shouldn't be draft. Provided these precautions you can use Information() as Yuri suggested. ie :
>
#INCLUDE 'wdconst.h'
>lcDir = getdir()
>lnDocs = adir(arrDocs,lcDir+'*.doc')
>lcSearch1 = 'First String to find'
>lcSearch2 = 'Next String to find'
>oWord=CREATEobject("Word.Application")
>With oWord
>  .Options.Pagination = .t.
>  For ix = 1 to lnDocs
>    .Documents.Open(lcDir+arrDocs[ix,1])
>    .ActiveDocument.ActiveWindow.View.Draft = .f.
>    With .ActiveDocument.Content.Find
>      .ClearFormatting
>      If .Execute(lcSearch1+'^w^p'+lcSearch2,.f.) ;
>          or .Execute(lcSearch1+'^p'+lcSearch2,.f.)
>        ? 'Found in document '+lcDir+arrDocs[ix,1]+;
>          ' at line '+transform(.Parent.Information(wdFirstCharacterLineNumber))
>      Endif
>    Endwith
>    .ActiveDocument.Close(wdDoNotSaveChanges)
>  Endfor
>  .Quit
>Endwith
>
This is not a bulletproof search and line number might change with just layout change. In your case getting the whole content to a string and making search in it might be more correct approach.
>Cetin

Thank you very much Cetin. One more question, is there any way to check if a "Selection" is inside of a table?
José Augusto Cavalcanti
Global Connection
jose.cavalcanti@globalconnection.com.br
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform