Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mailmerge using data from MySQL
Hi
I have been trying to set up a mail merge using data within a mysql database and using an ODBC connection. I have succeeded in setting this up and all 'test' connections are working fine, however when I click 'ok' within the 'connection' tab of the data link properties; I get a prompt appear entitled Mail Merge with the following statement contained within: 'Record 1 contained too few data fields' this repeats itself through each row of the database. Does anybody know of a way around this? I have tried the same set up using Open Office and that seemed to work. |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mailmerge using data from MySQL
If you're seeing the data link properties, you're probably actually
connecting via OLE DB, using the OLE DB provider for ODBC data sources, and in my experience Word doesn't usually work with that very well. In this case it's probably going to be easier doing the connection using VBA, in which case you need something like the following if you're using a system or user DSN: Sub Connect2mySQL() ActiveDocument.MailMerge.OpenDataSource _ Name:="", _ Connection:="DSN=your mySQL ODBC dsn name;PWD=your mySQL password;", _ SQLStatement:="SELECT * FROM mytable", _ SubType:=wdMergeSubTypeWord2000 End Sub or like the following if you're using a file DSN: Sub Connect2mySQL() ActiveDocument.MailMerge.OpenDataSource _ Name:="the full path name to your .dsn file", _ Connection:="FILEDSN=the full path name to your .dsn file;PWD=your mySQL password;", _ SQLStatement:="SELECT * FROM mytable", _ SubType:=wdMergeSubTypeWord2000 End Sub You might also need the UID= parameter (mySQL user ID) if it isn't in your DSN. You should only need to run the macro once to set up the data source - after you've saved the document, the connection should be re-made on re-open (forgetting about the SQL prompt). If you're not familiar with how to run VBA macros, see http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm Peter Jamieson "Phillip Dade" Phillip wrote in message ... Hi I have been trying to set up a mail merge using data within a mysql database and using an ODBC connection. I have succeeded in setting this up and all 'test' connections are working fine, however when I click 'ok' within the 'connection' tab of the data link properties; I get a prompt appear entitled Mail Merge with the following statement contained within: 'Record 1 contained too few data fields' this repeats itself through each row of the database. Does anybody know of a way around this? I have tried the same set up using Open Office and that seemed to work. |
Reply |
Thread Tools | |
Display Modes | |
|
|