Skip to main content
Participant
August 23, 2016
Question

Display file on screen when processing book

  • August 23, 2016
  • 1 reply
  • 822 views

Hi everyone,

I am working on a complex script to search and replace certain terms. In essence, it searches for the offensive term, shows it on the screen in the file and gives you a dialog box with a suggested edit. Everything works great, but when I'm processing a book, it doesn't pull up the found text range and display it on screen. If you run the script on just a single file, it works great and you can see the offensive term in context. But if you run it on the book and progress your way through the chapters, the file displayed on screen never changes. I know it's running because the display line at the bottom of the book window lists the file it's checking. It just would be nice for users to see the context of the offensive term.

I've tried calling ScrollToText and Redisplay just after finding the term and neither have any effect. I'm guessing that the focus is on the book and that prohibits the focus to switch to the file?

Any ideas or suggestions of things to try would be very much appreciated. I have scoured the scripting guide, and it's too obscure for a generic Google search to find anything.

With appreciation,

Heather Ayer

This topic has been closed for replies.

1 reply

4everJang
Legend
August 23, 2016

Hello Heather,

If oDoc is the document your script is processing, use

app.ActiveDoc = oDoc

to bring that document into view, then use ScrollToText etc.

Ciao

Jang

frameexpert
Community Expert
Community Expert
August 23, 2016

In addition to Jang's suggestion, you may need to make sure that the document is visible. Your book code may be opening the document invisibly. To do this, add this line before Jang's:

oDoc.IsOnScreen = 1;

-Rick

www.frameexpert.com
Legend
August 24, 2016

In addition to the suggestions from Jang and Rick, another way to really force a doc to the front is to "open" it again. A simple call like:

SimpleOpen(doc.Name, false);

Russ