Suppress the SQL message

K

Karen

From Access I have a button which opens Word, opens a mail merge document
and merges the Access record's data to a new doc based on the mail merge
doc. Everything works but when the mail merge starts, I get the following
message:

Opening this document will run the following SQL
command:............................

Is there any way to suppress this OR code I could add to my Access VBA when
I open the mail merge document so that 'Yes' is selected and the user isn't
prompted to say 'Yes'?
 
B

Billy Yao [MSFT]

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
 
K

Karen

Thanks Billy,

I don't have a problem with changing my registry, just wondered about the
wisdom of changing the registry for folks to whom I'll distribute this. I
guess I'll leave it up to them if they are using Word 2003 as I am.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top