Have a look at Helen Feddema's site:
http://www.helenfeddema.com/CodeSamples.htm
Among the samples are Access >>> Word automation code. One of the sample files (#24) shows four ways of merging data from Access to Word. No's 2, 3 and 9 are relevant as well.
Being unable to get a remote server (RPC server I believe in Office 97) usually is a sign that a procedure ended while failing to close a reference to an automation you set. It may also be a sign of an unavailable reference but in that case, the failure is not intermittent but consistent, at least in so far as the reference is available or not set on a particular machine.
I note you have dimensioned Word.Document and Word.MailMerge variables but have not used either. They are unnecessary with the code you have written. If you use them, destroy them in reverse order of 'Set'ting them.
Your error handler reads:
Set wrdApp = Nothing
oReport_Exit:
Exit Function
whereas it should read:
oReport_Exit:
On Error Resume Next
'Set wrdDoc = Nothing 'if you use it
Set wrdApp = Nothing
Exit Function
On the happening of an error, the error handler executes the way you have it written and the wrdApp object is not properly closed out. This could be the cause of the Remote server being unavailable. If you shut down Access and restart it, your code should probably create Word correctly at least the first time if this is the case, but not subsequent times.
Hardcoding the file names is a suspect practice. You'd do better to create a new doc from a template each time and then use the Dir function to determine if the file already exists in that location, and either kill it if it does, or change the name by incrementing a counter or appending a date/time as a suffix to the name or something of that nature. I'm not sure about wdDoNotSaveChanges being used for both the document and the application, particularly as you've previously saved changes but making sure you destroy all objects you create should prevent the remote server availablity error, assuming of course your reference to Word objects is valid.
Ciao
Jürgen Welz
Edmonton AB Canada
[email protected]