Find and highlighting the text and set the focus using Aspose.Words for Java

Hi,
I am Appichi from HCL Technologies.
I am using Aspose words for java to Find and highlighting the text. Using example program i can able to do find & highlight the item. But i cannot able to focus the page.(Example my searched content is in P#4 it is always showing P#1). If anybody have the code please share. Please do the needful

Hi Appichi,
This is very easy to find and highlight text using Aspose.Words.You can find an example here:
https://docs.aspose.com/words/net/find-and-replace/
Thanks and Regards,

dihsarashid

Hi dihsarashid ,
I have used example code only. But I need to set the focus for the current page(Navigate to the Content). Example my searched content is in P#4 it should show the p#4 not P#1.

Hi there,

Thanks for your inquiry.

I’m afraid there is no view option or command line switch that will allow you to open a document at a particular page.

You can however still achieve what you are looking for by using a macro in your template document. For instance you can do something like this:

  1. Include a macro with your template document which runs automatically when the document is opened.
  2. When you replace your text in your application you can also write a bookmark at the same location as well. The name can be “ScrollToLocation”.
  3. The macro when executed on start up can then check to see if the “ScrollToLocation” bookmark exists, if it does then it can invoke a command to move the document view down to this bookmark.

If we can help with anything else please feel free to ask.

Thanks,

Hi,
Can u send the sample code for the above comment.
Thanks in Advance.
Regards
Appichi

Hi Appichi,
Thanks for your request. There is no way to create macros programmatically using Aspose.Words. What Adam suggested is creating macro manually in MS Word.
Best regards,