Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mail Merge with Word Problem
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00712811
Message ID:
00713179
Views:
17
Ok, most likely you need sqlstatement like:
lcSQLStatement = ["SELECT * FROM db!contacts WHERE Contacts.co_primary = ?vPrimary"].

Here is the code that works for me (txt file below is delimeted file):
VBA macro code:
*.ActiveDocument.MailMerge.OpenDataSource Name:="C:\iftp_log_viewonly.txt", _
*ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
*AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
*WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
*Format:=wdOpenFormatAuto, Connection:= _
*"DSN=Text Files;DBQ=C:\;DefaultDir=C:\;DriverId=27;MaxBufferSize=2048;PageTimeout=5;" _
*, SQLStatement:="SELECT * FROM iftp_log_viewonly.txt", SQLStatement1:=""

VFP code:
.OpenDataSource(;
"C:\iftp_log_viewonly.txt",,,,,,,,,,,;
"DSN=Text Files;DBQ=C:\;DefaultDir=C:\;DriverId=27;MaxBufferSize=2048;PageTimeout=5;"+;
'SQLStatement:="SELECT * FROM iftp_log_viewonly.txt"')

As you see, sqlstatement here even does not separated by comma from the previous portion (though comma if included will not harm), but is included into the connection string with 'SQLStatement' keyword.

>Thanks for the reply. Yes I had done that (several times in fact) - when I used that connection string it brought up the messagebox that expects you to define the type of delimiter you want to use for the merge etc. This is normally caused when you do a merge into Word and choose "Foxpro Files = Word" as a datasource. I have tried also getting a connection from VBs dataenvironment tool just to compare! As I say with the oWord.ActiveDocument.MailMerge.DataSource.ConnectionString I expected to get back the correct connection string! but no joy.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform