PDA

View Full Version : Word VBA, OpenDataSource, Statement option



jerry00769
01-31-2016, 07:14 AM
Hello,

please, does anyone know how to continue with this Word VBA command in complience with this image?
15323

I would like to connect with Excel Workbook Name: SEZNAM.XLS, Sheet Name: "Soukromé osoby" and also set up merge filter filed name = "jméno_1" is not empty > is not null...

My command (DDE connection must be) is: ActiveDocument.MailMerge.OpenDataSource Name:=ThisDocument.Path & "\SEZNAM.XLS", SQLStatement:="SELECT * FROM [Soukromé osoby]", SubType:=wdMergeSubTypeWord2000
It's ok but after that I recieve this dialog (sorry in Czech) > Cell contents or named area: must be "Celý list" (Whole Sheet)
15324

My next attempt of command was not successful: ActiveDocument.MailMerge.OpenDataSource Name:=ThisDocument.Path & "\SEZNAM.XLS", SQLStatement:="SELECT * FROM [Soukromé osoby]" & "WHERE [jméno_1] = _NULL", SubType:=wdMergeSubTypeWord2000
There is no named area "Celý sešit"....

Please, please help

Thanks so much in advance.

Jerry

gmayor
01-31-2016, 09:57 PM
You receive the "Opening this will run the following SQL command" message when you open a Word mail merge main document that is linked to a data source - http://support.microsoft.com/?kbid=825765. See also the Word macro to toggle the registry setting referred to in that link at http://www.gmayor.com/word_vba_examples.htm.