Overcoming Worksite dialog with VBA

85 Views Asked by At

All

I have a database which exports to a word document (via a report saved as an excel document). Essentially access exports the report, opens it and word, and then parses the data into a word table. There are a handful of reasons it's done this way, rather than just exporting the report directly to word, and it all works fine.

Until...

We have worksite / filesite integration, and so if you are not connected to the local network, worksite prompts you during word startup for the relevant document server, or ask if you want to operate offline, or operate locally. The problem I have is that because all of the word document creation isn't visible (and I'd prefer for it not to be), there's no way of answering this prompt.

We can resolve this by just saying "if you're not connected to the network, you need to open an instance of word before you try exporting." But that's annoying, and also people just forget, with the result that the export just hangs (there's no error to handle), and you have to manually end the word (and excel) processes though task manager.

Is there a way to e.g.,

  • Run a timer in parallel, which is set going just before the create.object("Word Application") line, and when it gets to a certain point (say 20 seconds) and the code hasn't advanced, then it just assumes something's gone wrong and makes word visible?
  • Or to detect the presence of the filesite dialog?
  • Or, ideally, just provide the input for the dialog programatically (i.e. "click" the Local button)(the user is prompted for an export location, which is always local)?
0

There are 0 best solutions below