Hi,
I am currently evaluating Aspose.Words to migrate and significantly enhance Macros our users have locally onto a central server (the plan is to run the code as the documents pass through our email gateway). Alot of the existing code makes use of the “Find” object in VBA.
I’ve read the below article, and looked elsewhere in the documentation - but can’t really find an easy way to “Find” within a document. To be clear I do not want to replace any text, but rather return a Range object which points to a specific text string, and then harvest subsequent text strings for storage elsewhere. In time I will probably want to manipulate based on found Ranges, and volumes could be significant so being able to find text efficiently is quite important.
https://docs.aspose.com/words/net/find-and-replace/
The first paragraph seems to suggest “finding” can be done with this method - but doesn’t explain how. It seems more like just Replace. Suppose for example I want to find the first instance of “Author:” and return a Range for it. In VBA this would be;
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:=“Author”, Forward:=True 'myRange is redefined to a new range which is the found text.
I had looked at Aspose.Cells first (we also do a similar process on Excel reports) and it does have the kind method I was looking was able to prototype what I’m trying to do quite quickly;
Cell cell = worksheet.Cells.FindStringStartsWith("Author:", null);
Additionally the Find method in VBA is also very useful in that it can Find not just “Author:” string, but also “Author:” strings which are Bold, 12pt, Italic etc. qnd use special characters (i.e. “^p”) to locate the end of paragraphs etc. I anticipate this coming in handy as we begin to enhance our processes server side; so was wondering if this is supported by Aspose.Words in a straightforward way? One of the big judgments of success in the project will be the extent to which we can reduce the code we need to maintain and simplify it so it can be worked on by developers with less risk. I did see some code here (https://docs.aspose.com/words/net/find-and-replace/) which I may be able to re-engineer to achieve what I’m after but it seems like it could end up being alot of code to do something which seems like a common requirement.
I am hoping the functionality is there and I’ve just missed it and there is at least an equivalent to the Aspose.Cells Find functionality in Aspose.Words.
Thanks for your attention to this.
This message was posted using Page2Forum from Find and Replace Overview - Aspose.Words for .NET and Java