Hi Karen,
Thank you for posting in the community.
From your description, you would like to open a mail merge template in Word 2003.
However, you received the following message:
"Opening this will run the following SQL command:"
and the KB 825765 mentioned you could follow the method to add the "SQLSecurityCheck"
registry key to suppress this message. I understand you'd like to pursue some VBA solution
if possible.
I performed a further test with the following code, create a doc1.doc file on disk C,(type
some characters in the Word file). when the mail merge starts, I found this message didn't
appear in Word 2002/2000. In Word 2003,however, the message persists.
'''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()
Dim oApp As Word.Application
Dim oDoc As Word.Document
'Create a new document in Word.
Set oApp = New Word.Application
Set oDoc = oApp.Documents.Open("C:\doc1.doc")
'Make Word visible.
oApp.Visible = True
With oDoc.MailMerge
.DataSource.ActiveRecord = wdLastRecord
'Display the number of records that will be merged.
Ret = MsgBox(.DataSource.ActiveRecord & " records will be " & _
"merged. Click Yes to continue or No to quit.", _
vbYesNo + VbMsgBoxSetForeground)
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''
Based on my further researching, I found out that in Word 2003 it will display a message box
by default when you try to open a Word 2003 mail merge document that is linked to a data
source.
The default value is No and it will not run the SQL command. To make the SQL command
code
work, we need to create the following registry key and explicitly set its value 0:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\Options
"SQLSecurityCheck"=dword:00000000
Therefore, I need to say that there is no VBA solutions till now as the issue is by-design in
Word 2003. I wonder if you accept the method to add the "SQLSecurityCheck" registry key
to suppress the message. If you have any concerns, please feel free to let me know.
Best regards,
Billy Yao
Microsoft Online Support