473,705 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to create mail merge with word 2003 and sql server 2000 as database

11 New Member
hi, i have the following command and generated an error :
"word was unable to open the data source"

any help will be greatly appreciated.

Thanks in advance.

Jude

Private Sub Command1_Click( )

Dim oMainDoc As Word.Document
Dim oSel As Word.Selection
Dim sDBPath As String

'Start a new main document for the mail merge.
Set oMainDoc = oApp.Documents. Add

With oMainDoc.MailMe rge

.MainDocumentTy pe = wdFormLetters

.OpenDataSource Name:="", _
connection:="DS N=JLU;DATABASE= PAMI_DB;UID=;pw d=;", _
sqlstatement:=" select * from TBLUSERINFO"
'Add the field codes to the document to create the form letter.
With .Fields
Set oSel = oApp.Selection
.Add oSel.Range, "USERID"
oSel.TypeParagr aph
.Add oSel.Range, "LASTNAME"
oSel.TypeParagr aph
.Add oSel.Range, "FIRSTNAME"
oSel.TypeText ", "
.Add oSel.Range, "MI"
oSel.TypeParagr aph
oSel.TypeParagr aph
oSel.TypeText "Dear "
.Add oSel.Range, "FULLNAME"
oSel.TypeText ","
oSel.TypeParagr aph
oSel.TypeParagr aph
oSel.TypeText " This letter is to inform you..."
oSel.TypeParagr aph
oSel.TypeParagr aph
oSel.TypeText "Sincerely, [Your Name Here]"
End With
End With

'Perform the mail merge to a new document.
With oMainDoc
.MailMerge.Dest ination = wdSendToNewDocu ment
.MailMerge.Exec ute Pause:=False
End With

End Sub
Sep 27 '07 #1
2 3337
davef
98 New Member
Make sure your connection string is valid.
Sep 27 '07 #2
jojopangit
11 New Member
hi, tried this one but no luck again. it gave no error but my computer does not have any activity.


With oMainDoc.MailMe rge

.MainDocumentTy pe = wdFormLetters
.OpenDataSource Name:="", _
connection:="Pr ovider=SQLOLEDB .1;Integrated Security=SSPI;P ersist Security Info=False;Init ial Catalog=pami_db ;Data Source=JLU", _
sqlstatement:=" select * from TBLUSERINFO", SubType:=wdMerg eSubTypeWord200 0
With .Fields
Set oSel = oApp.Selection
.Add oSel.Range, "USERID"
oSel.TypeParagr aph
.Add oSel.Range, "LASTNAME"
oSel.TypeParagr aph
.Add oSel.Range, "FIRSTNAME"
oSel.TypeText ", "
.Add oSel.Range, "MI"
oSel.TypeParagr aph
oSel.TypeParagr aph
oSel.TypeText "Dear "
.Add oSel.Range, "FULLNAME"
oSel.TypeText ","
oSel.TypeParagr aph
oSel.TypeParagr aph
oSel.TypeText " This letter is to inform you..."
oSel.TypeParagr aph
oSel.TypeParagr aph
oSel.TypeText "Sincerely, [Your Name Here]"
End With
End With

With oMainDoc
.MailMerge.Dest ination = wdSendToNewDocu ment
.MailMerge.Exec ute Pause:=False
End With
Sep 28 '07 #3

Sign in to post your reply or Sign up for a free account.

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...
9
4322
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
5583
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...
0
1248
by: Martin Feuersteiner | last post by:
Dear Group I wondered whether there's an ASP.NET example on how to automate word to perform a client-side mail merge? It looks like many people are asking the same question but haven't found a proper up-to-date ASP.NET solution. Microsoft Knowledge Base Article - 285176 refers to ASP http://support.microsoft.com/default.aspx?scid=kb;EN-US;q285176
4
3897
by: Access | last post by:
Okay I know this is probably not the best way to be doing things but I have an ancient application that was working fine until a end user got a new machine. The Access database is performing a mail merge. The Word Document is linked to a temp table in the Access database. It used to work fine in the past with DDE. Yes it opens another copy of the database but it doesn't really matter and it worked. So now with Access 2003 and Word...
0
1537
by: pnr | last post by:
I transferred my database to a new computer. I can open it in 2003 Access, but am keeping it in the 2000 version until I get it working correctly. I have dozens of Word documents where I use various Access queries as my datasource. Now when I try to mail merge in Word (for some, not all, of my documents.) Word mail merge message may say it can't find the data source. So it gives me a data selection box and I choose my transferred...
5
3722
by: johnvon | last post by:
I have a mail merge that runs flawlessly in Access 2000. In 2003 I keep getting dialog boxes that I can't figure out how to supress. Several of them are telling me that Admin (me!) has the database opened (duh!). I then get a logon dialog box, which I cancel. The merge then runs perfectly! How do I supress all of these dialog boxes. Thanks! John
0
1802
by: Darragh | last post by:
I'm encountering some serious problems trying to set Access 2000 querys (parameters and views) as data sources for my mail merge documents (Word 2003). After spending hours scouring the web for some existing help and coming up with nothing, its time to admit defeat and ask here ! Trying to set the data source to a preexisting query via DDE results in an 'Unable to establish DDE connection' - similar to the error described at...
7
4163
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;
0
8691
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,...
0
9275
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9140
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7895
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
6607
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
4441
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...
1
3140
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2492
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2084
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.