Document_New() VS. Bookmarks...Sequence

P

paulmac106

A user opens a word template from an Access application, Bookmarks are
filled...then I have some code under Document_New.

I need to capture a string insterted by the bookmark, then run my code.

The problem is that Document_New seems to fire before the bookmarks are
filled...thus giving me an empty string.

Do you know of any workarounds?

thanks,
Paul

btw, the Access Application is store bought, so I can't program within
it.
 
J

Jezebel

Nothing 'seems to' about it. Document_New, by definition, is fired when the
document is created and before anything is done to it.

You could try monitoring the WindowsSelectionChange event -- depending on
how the Access app works, there may be some sequence of selections you can
recognize and act on.

Or you could start a timer in Document_New, wait 30 seconds (or however long
the access app takes), then run your code.

Or start a loop that idles a while then checks the value of your bookmark,
and loops until it changes.

Or monitor the task manager, watching until the access app has finished.
 
P

paulmac106

It looks like loops and timers happen before the bookmarks fill too.

could you tell me more about WindowsSelectionChange

thanks,
Paul
 
J

Jezebel

WindowsSelectionChange is one of the events fired by Word -- fired each time
the selection changes. It will help in your case only if the Access app uses
the selection to make its changes, as opposed to working with Range objects.

To trap it you need a class module with a WithEvents reference to the Word
application object. There's an example in Help under a topic called
something like "Working with Word events".
 
Top