473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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="""";Us er 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
Sep 11 '06 #1
2 10866
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.

Sep 12 '06 #2
Peter

Thanks for the reply

Problem solved

Regards
Steve

""Peter Huang" [MSFT]" <v-******@online.microsoft.comwrote in message
news:14*************@TK2MSFTNGXA01.phx.gbl...
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.

Sep 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: antonovaCCCS | last post by:
In our old VB 6 application we utilize a mail merge feature of Word 97 with MS Access. A table in Access is populated from VB and a Word template is wired to that table. So all we do in the code is...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
9
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
4
by: lesperancer | last post by:
I have 3 tables (office97) tblQuote quoteNbr tblDetails ( quote : 1 <-> M: quoteDetails) quoteNbr detailLine product value
6
by: crealesmith | last post by:
Firstly, I have no problem with mail merging to Word, VB code for that works perfectly. On one mail merge I need to merge 15 fields of data that are from 3 seperate records. The 3 records are all...
7
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to follow a mail merging example in C#.Net that I got from: http://support.microsoft.com/default.aspx/kb/301659 and in one the methods: Word.Application wrdApp; Word._Document...
2
by: diston52 | last post by:
Good afternoon. My name is Don, and I'm working with my first dealings with Mail Merge. I have been reading a discussion started by a user called Chubbly Geezer, and have been trying different...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.