Mail merge from word using sql server express and vb.net 2005

S

steve

Hi All

What is the word mailmerge.opendatasource syntax when using sql server
express as the data source

Below is the code when using access....
odoc.MailMerge.OpenDataSource(Name:= _

"C:\Program Files\Geelong Microsolutions\Haircuts\Data\u2.mdb",
ConfirmConversions:=False, _

Connection:= _

"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data
Source=C:\Program Files\Geelong Microsolutions\Gym
Master\Data\u2.mdb;Mode=Read;Jet OLEDB:Engine Type=" _

, SQLStatement:="SELECT * FROM `Customers`", SQLStatement1:="")



Regards

Steve
 
P

Peter Huang [MSFT]

Hi Steve,

Based on my understanding, you want to mailmerge against a SQL 2005 Express
DB and you want to know what is the parameter for the OpenDataSource.

Word provides strong Macro record function, we can simple use that function
to record the macro that we do the mailmerge against SQL 2005 Express DB
manually and get the code we wants.
1. Tools/Macro/Record New Macro
2. Run the MailMerge in Word by manually
3. Stop the macro recording
4. Press Atl+F11 to View the Recorded macro

Here is an example I record for your reference.

Sub Macro1()
'
' Macro1 Macro
'
ActiveDocument.MailMerge.MainDocumentType = wdMailingLabels
ActiveDocument.MailMerge.OpenDataSource Name:= _
"<path to a odc file>" _
, 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=encrypt;Data Source=<sqlexpress instance>;Use
Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation
ID=<machinename>;Use Encryption for Data=F" _
, SQLStatement:="SELECT * FROM ""employee2""", SQLStatement1:="",
SubType _
:=wdMergeSubTypeOther
End Sub

Please have a try and let me know the result.
If you have any concern, please feel free to let me know.


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top