I stumbled on a strange issue yesterday while working at a customer site. The automated mail merge was failing in Word 2003 when called from my script.
After performing some research, the reason for the failure was an interactive prompt waiting for a response. If I has used vbscript, I suppose I could have suppressed the alerts but I do not want to suppress all alerts, just this one.
The prompt was introduced in all versions of office after office XP SP3 as a security patch.
For further information, refer to the following link:
http://support.microsoft.com/kb/825765
The workaround involves editing the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\Options
You then need to add the DWORD value SQLSecurityCheck and set this to 00000000
You can do this remotely using registry editor by using the Connect to Remote Registry option. The difference is that this will only grant you access to the HKEY_Local_Machine (HKLM) or the HKEY_USERS (HKU) keys.
The key here, is that the HKEY_Current_User key loads its' information dynamically from the HKEY_Users key using the GUID of the connected user. Information saved to the HKEY_Current_User key is saved also to the HKEY_USERS key and vice versa.
So, using the HKEY_USERS key, if you know the GUID for the connected user, make the change to their key and save. If you do not know the GUID of the connected user, expand each GUID past \Software\Microsoft\ and only the GUID for the connected user (or users who have connected interactively) will show the full path. Make the change at that point. Agreed that in the case where the computer is shared, the change may need to be made several times... Use Copy & Paste to facilitate the change in that case.
This change takes effect immediately and only requires you to close and open Word to work.
Read the complete post at http://owsug.ca/blogs/brad/archive/2008/09/04/Mail-merge-automation-fails-in-MS-Word-when-linked-with-a-data-source.aspx