Hi my name is josua,
I've problem.
When I open file M.word,
The popup window show
"
Opening this document will run the following SQL command:
SELECT * FROM 'student verification data$'
etc......
"
How to change this SQL commad, cause I want to add 'where' statement in this
SQL command.
I use excel as database and I use Ms office 2007.
regards,
josua
nb: sorry if my english is bad :)
Doug Robbins - Word MVP - 10 Aug 2007 04:49 GMT
That message is actually a security warning. See the following web page:
"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:
http://support.microsoft.com?kbid=825765

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi my name is josua,
>
[quoted text clipped - 22 lines]
> josua
> nb: sorry if my english is bad :)
Peter Jamieson - 10 Aug 2007 07:31 GMT
There are two main possible ways:
1. Use the Advanced Query Options to specify the criteria you want:
a. open your document, and accept the existing SQL command
b. Word 2007 ribbon->Mailings tab->Edit recipient list
c. Click the drop-down arrow in the heading of one of the columns of data
in the list, and select (Advanced...)
d. Enter your criteria in the boxes
2. Use Word VBA to open the data source, e.g.
Sub OpenMyDataSource()
ActiveDocument.MailMerge.OpendDataSource _
Name:="the full path name of your .xls", _
SQLStatement:="SELECT * FROM [student verification data$] WHERE ...your
criteria..."
End Sub
You may find that you cannot get (1) to work and that you have to use (2).
You should only need to execute this macro once (not each time you open the
document).
For some more info on how to do this, see
http://word.mvps.org/FAQs/Macros/VBA/CreateAMacro.htm
(However, in Word 2007 you will need to do things slightly differently,
starting from the Developer tab in the ribbon).
Peter Jamieson
> Hi my name is josua,
>
[quoted text clipped - 22 lines]
> josua
> nb: sorry if my english is bad :)