Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.dotnet.languages.vb,microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mailmerge Automation Problems
Many thanks.
Seems the problem went away by removing the Connection and SQLStatement strings. "Peter Jamieson" wrote in message ... You probably need something more along the following lines. In VBA you shouldn't need the other parameters (most of them have no effect) but if you do, put them back wrdDoc.MailMerge.OpenDataSource(Name:="C:\Document s and Settings\pd.ISL\My Documents\My Data Sources\webdev Subscriptions2 SubscriptionsPrintQueue.odc", Connection:="Provider=SQLNCLI.1;Data Source=WEBDEV;Integrated Security=SSPI;Initial Catalog=Subsscriptions2;", SQLStatement:="select * from ""subscriptionsprintqueue""", SubType:=Word.WdMergeSubType.wdMergeSubTypeOther) This assumes that you are using the "Native Client" OLEDB provider for SQL Server 2005 access. You may still be able to use the old provider by specifying Provider=SQLOLEDB.1 instead. You may need to specify the Data Source as SERVERNAME\WEBDEV where you substitute your server name. As long as the Connection and SQLStatement parameters contain everything you need you can probably get away with a completely empty .odc file. The double quotes around the table name in the Select statement are probably optional. Peter Jamieson "Chubbly Geezer" wrote in message ... Hi Peter yes the Word UI can complete the merge. Have already tried as suggested below, but get the same problem as before when I either run the Macro from within Word or run the code from within VB. When I try to execute, word shows a pop up stating that my merge field does not exist. Would I like to remove it or use field 'M__' or 'M__1'.? Chubbly ""Peter Huang" [MSFT]" wrote in message ... Hi Chubbly, Firstly I assume that you can use Word UI interactive operation to complete the MailMerge with the same DB. I suggest you tried to follow the steps to retrieve the Macro to do mail merge which is the same as we do in VB.NET. 1. Tools/Macro/Record Macro 2. Start your interactive operation of Mail Merge procedure and complete that. 3. stop macro record 4. Press Alt+F11 to open the macro you recorded just now. It should be similar with below. ActiveDocument.MailMerge.OpenDataSource Name:= _ "path\odc" _ , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _ AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _ WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _ Format:=wdOpenFormatAuto, Connection:="", SQLStatement:="", SQLStatement1 _ :="", SubType:=wdMergeSubTypeOther This is the code you will use for your VB.NET program. Please have a try and let me know the result. Thanks! Best regards, Peter Huang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error to Automation mailmerge to printer in word 2003 | Mailmerge | |||
get error 5361 in mailmerge automation | Mailmerge | |||
Mailmerge Querystring Problems | Mailmerge | |||
Problems with Mailmerge and odc | Mailmerge | |||
Problems (again) getting Outlook contacts in Word 2002 Mailmerge | Mailmerge |