View Single Post
  #8   Report Post  
Posted to microsoft.public.dotnet.languages.vb,microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default Mailmerge Automation Problems

A problem with Word is that it truncates the Connection string when it
records it. If you delete "Tag with colum" from the end, it will probably
work.

Peter Jamieson

"Chubbly Geezer" wrote in message
...
As mentioned, this is what the macro records. When doing this manually,
the doc will merge no problem. When running this macro I get the error.

ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\pd.ISL\My Documents\My Data
Sources\webdev Subscriptions2 SubscriptionsPrintQueue.odc" _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=True;Initial Catalog=Subscriptions2;Data Source=webdev;Use Procedure
for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation
ID=WGVWXL1J;Use Encryption for Data=False;Tag with colum" _
, SQLStatement:="SELECT * FROM SubscriptionsPrintQueue", _
SQLStatement1:="", SubType:=wdMergeSubTypeOther



"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.