Hi,
I am trying to find the best way to read a specific paragraph from a word document, I was hoping to use Comate Plus but the only way I can do it is by reading the whole document and then finding the Paragraph that I require. As the documents are very large it is very slow to do it this way. I thought I saw a way of reading just one paragraph in Comate but I can not find it. I have tried to figure it out but I just can not get it to work.
I know the paragraph number or I can get it from a table in the document.
Does anyone have some working code I can have a look at.
Thanks
How do i read specific paragraph with Comate
How do i read specific paragraph with Comate
Regards
Leo
Leo
Re: How do i read specific paragraph with Comate
Code: Select all
IncludePath "[YourPathTo]\COMatePLUS\"
XIncludeFile "COMatePLUS.pbi"
Procedure ShowErrorIfAny()
If COMate_GetLastErrorCode() : Debug COMate_GetLastErrorDescription() : EndIf
EndProcedure
Define WordApplication.COMateObject
Define WordDocument.COMateObject
Define WordParagraph.COMateObject
WordApplication = COMate_CreateObject("Word.Application")
If WordApplication
WordDocument = WordApplication\GetObjectProperty("Documents\Open('[Your.Doc]')")
If WordDocument
AmountOfParagraphs = WordDocument\GetIntegerProperty("Paragraphs\Count")
For ParagraphCounter = 1 To AmountOfParagraphs
WordParagraph = WordDocument\GetObjectProperty("Paragraphs(" + Str(ParagraphCounter) + ")")
If WordParagraph
Debug WordParagraph\GetStringProperty("Range\Text")
WordParagraph\Release()
Else
Debug "!WordParagraph"
ShowErrorIfAny()
EndIf
Next
WordDocument\Release()
Else
Debug "!WordDocument"
ShowErrorIfAny()
EndIf
WordApplication\Invoke("Quit")
WordApplication\Release()
Else
Debug "!WordApplication"
ShowErrorIfAny()
EndIfHygge
Re: How do i read specific paragraph with Comate
@ Kiffi
Thanks for that, It works perfectly.
All the best and Happy New Year.
Thanks for that, It works perfectly.
All the best and Happy New Year.
Regards
Leo
Leo

