473,671 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi All

What is the word mailmerge.opend atasource 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\u 2.mdb",
ConfirmConversi ons:=False, _

Connection:= _

"Provider=Micro soft.Jet.OLEDB. 4.0;Password="" "";User ID=Admin;Data
Source=C:\Progr am Files\Geelong Microsolutions\ Gym
Master\Data\u2. mdb;Mode=Read;J et OLEDB:Engine Type=" _

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

Regards

Steve
Sep 11 '06 #1
2 10880
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.MainD ocumentType = wdMailingLabels
ActiveDocument. MailMerge.OpenD ataSource Name:= _
"<path to a odc file>" _
, ConfirmConversi ons:=False, ReadOnly:=False , LinkToSource:=T rue, _
AddToRecentFile s:=False, PasswordDocumen t:="",
PasswordTemplat e:="", _
WritePasswordDo cument:="", WritePasswordTe mplate:="",
Revert:=False, _
Format:=wdOpenF ormatAuto, Connection:= _
"Provider=SQLOL EDB.1;Integrate d Security=SSPI;P ersist Security
Info=True;Initi al Catalog=encrypt ;Data Source=<sqlexpr ess instance>;Use
Procedure for Prepare=1;Auto Translate=True; Packet Size=4096;Works tation
ID=<machinename >;Use Encryption for Data=F" _
, SQLStatement:=" SELECT * FROM ""employee2 """, SQLStatement1:= "",
SubType _
:=wdMergeSubTyp eOther
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.m icrosoft.comwro te in message
news:14******** *****@TK2MSFTNG XA01.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.MainD ocumentType = wdMailingLabels
ActiveDocument. MailMerge.OpenD ataSource Name:= _
"<path to a odc file>" _
, ConfirmConversi ons:=False, ReadOnly:=False , LinkToSource:=T rue, _
AddToRecentFile s:=False, PasswordDocumen t:="",
PasswordTemplat e:="", _
WritePasswordDo cument:="", WritePasswordTe mplate:="",
Revert:=False, _
Format:=wdOpenF ormatAuto, Connection:= _
"Provider=SQLOL EDB.1;Integrate d Security=SSPI;P ersist Security
Info=True;Initi al Catalog=encrypt ;Data Source=<sqlexpr ess instance>;Use
Procedure for Prepare=1;Auto Translate=True; Packet Size=4096;Works tation
ID=<machinename >;Use Encryption for Data=F" _
, SQLStatement:=" SELECT * FROM ""employee2 """, SQLStatement1:= "",
SubType _
:=wdMergeSubTyp eOther
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
2869
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 call the merge method of Word. Problem: We are moving to VB.NET (VS 2005) and Office 2003. I want to bypass Access and either use a connection to SQL or a parametrized stored procedure. I found some samples, but was not able to open the...
8
9513
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 each person for whom a mail merge letter is desired. The query reads address info from the table for each record where is true.
9
4321
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 application as the data source, and then performs a merge. Everything works fine. However, when a user uses it in Access 2002 and Word 2002, an extra instance of the Access application is opened and remains open at the end. Sometimes it remains open
3
5580
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 document in Word; 2. opens the document and runs the merge process for the new data. I have managed to write the code to perform step 1 ok, but I'm having trouble with step 2. It opens the word document fine but does not perform the mail merge of...
4
5447
by: lesperancer | last post by:
I have 3 tables (office97) tblQuote quoteNbr tblDetails ( quote : 1 <-> M: quoteDetails) quoteNbr detailLine product value
6
4642
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 in the same table. If I use a control source that is selecting the 3 records, all of the data is shown but spread over 3 pages in the mail merge, but needs to be listed together in one paragraph. Is there anyway of looping through the 3...
7
4156
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 wrdDoc; Object oMissing = System.Reflection.Missing.Value; Object oFalse = false;
2
1749
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 solutions presented to him. I am using VB from Visual Studio 2005, and SQL Server 2005 Express as a backend, with Office 2003. My SQL Server is set up with Mixed security. I am trying to use the doc.MailMerge.OpenDataSource in my code to cause the work...
1
5051
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 very little (actually probably nothing) about VBA and I'm currently learning my way around Access. Basically, I want to click a button in the form that merges the letter for me, only for the one record I'm currently viewing..not the whole...
0
8397
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8599
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6230
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.