PC Review


Reply
Thread Tools Rate Thread

Problem with mail merge

 
 
=?Utf-8?B?QW1vdXI=?=
Guest
Posts: n/a
 
      2nd Aug 2007
Hi, I am really new to Access and Word (2003)
I want to mail merge but for some reason it is not filling in the << Name >>
all the fields. What I want is to automaticly open the word document (this
works) and to automaticly populate the fields (this is the problem). This is
in the VB function:

Function mergeinfo(docum, textfile, sqlstr)
On Error GoTo Error_AccessToWord
Dim WordDoc As Object
Dim constr As String

On Error Resume Next
Set appWord = GetObject(, "Word.Application")
If Err.number <> 0 Then
MsgBox "Starting Word . . . "

Err.Clear
Set appWord = CreateObject("Word.Application")
End If
Set WordDoc = appWord.Documents.Open(textfile)

'Enable viewing the Word session and its document
appWord.Visible = True

With WordDoc.MailMerge
' constr = "DSN=MS Access 97 " _
& "Database;DBQ=s:\asbdata\asb2\asbdata.mdb;" _
& "FIL=MS Access;"

'.OpenDataSource "s:\asbdata\asb2\asbdata.mdb", , , True, True, , ,
, , , , constr, sqlstr

WordDoc.MailMerge.OpenDataSource
Name:="C:\asb6\datafiles\letter03file.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE tblTempBTO", _
sqlstatement:="SELECT * FROM [tblTempBTO]"

.Destination = wdSendToNewDocument
'Execute the mail merge

WordDoc.MailMerge.Execute
End With
'WordDoc.Close (wdDoNotSaveChanges)
Exit Function


Error_AccessToWord:
AppActivate "Microsoft Access"
Beep
MsgBox "The Following Automation Error has occurred:" & vbCrLf &
Err.Description, vbCritical, "Automation Error!"
Exit Function


End Function


I heard something about a recordsource but I don't know if it is
within the main word document or within VB as a statement and if so then how
would I right this statement.

Also I looked at: "Albert's Super
Easy Word Merge" but this did the samething. It just opens the document
with << field name >> and what I want is for it to auto populate the field
when opening document.

I tried though MS-Word to:

TOOLS: Letters and Mailings: Mailmerge: Next: Next: Browse: Select Datafile
that has data to merge: Select Table: Mailmerge Recipients: Next: More Items:
Select field to insert:.

Then I saved the document and ran the program (no change).


WHAT AM I DOING WRONG!

Thank You for any help!


 
Reply With Quote
 
 
 
 
pietlinden@hotmail.com
Guest
Posts: n/a
 
      2nd Aug 2007
What happens if you set up the merge manually? Can you see the merged
data?

 
Reply With Quote
 
=?Utf-8?B?TXIgQg==?=
Guest
Posts: n/a
 
      3rd Aug 2007
Amour,

Take a look at Albert Kallal's Super Easy Word Merge code:

http://www.members.shaw.ca/AlbertKal.../msaccess.html

It really works great. I've used it several times with no problems!

Thanks, Albert!

--
HTH

Mr B
askdoctoraccess dot com


"Amour" wrote:

> Hi, I am really new to Access and Word (2003)
> I want to mail merge but for some reason it is not filling in the << Name >>
> all the fields. What I want is to automaticly open the word document (this
> works) and to automaticly populate the fields (this is the problem). This is
> in the VB function:
>
> Function mergeinfo(docum, textfile, sqlstr)
> On Error GoTo Error_AccessToWord
> Dim WordDoc As Object
> Dim constr As String
>
> On Error Resume Next
> Set appWord = GetObject(, "Word.Application")
> If Err.number <> 0 Then
> MsgBox "Starting Word . . . "
>
> Err.Clear
> Set appWord = CreateObject("Word.Application")
> End If
> Set WordDoc = appWord.Documents.Open(textfile)
>
> 'Enable viewing the Word session and its document
> appWord.Visible = True
>
> With WordDoc.MailMerge
> ' constr = "DSN=MS Access 97 " _
> & "Database;DBQ=s:\asbdata\asb2\asbdata.mdb;" _
> & "FIL=MS Access;"
>
> '.OpenDataSource "s:\asbdata\asb2\asbdata.mdb", , , True, True, , ,
> , , , , constr, sqlstr
>
> WordDoc.MailMerge.OpenDataSource
> Name:="C:\asb6\datafiles\letter03file.mdb", _
> LinkToSource:=True, AddToRecentFiles:=False, _
> Connection:="TABLE tblTempBTO", _
> sqlstatement:="SELECT * FROM [tblTempBTO]"
>
> .Destination = wdSendToNewDocument
> 'Execute the mail merge
>
> WordDoc.MailMerge.Execute
> End With
> 'WordDoc.Close (wdDoNotSaveChanges)
> Exit Function
>
>
> Error_AccessToWord:
> AppActivate "Microsoft Access"
> Beep
> MsgBox "The Following Automation Error has occurred:" & vbCrLf &
> Err.Description, vbCritical, "Automation Error!"
> Exit Function
>
>
> End Function
>
>
> I heard something about a recordsource but I don't know if it is
> within the main word document or within VB as a statement and if so then how
> would I right this statement.
>
> Also I looked at: "Albert's Super
> Easy Word Merge" but this did the samething. It just opens the document
> with << field name >> and what I want is for it to auto populate the field
> when opening document.
>
> I tried though MS-Word to:
>
> TOOLS: Letters and Mailings: Mailmerge: Next: Next: Browse: Select Datafile
> that has data to merge: Select Table: Mailmerge Recipients: Next: More Items:
> Select field to insert:.
>
> Then I saved the document and ran the program (no change).
>
>
> WHAT AM I DOING WRONG!
>
> Thank You for any help!
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge Prompt for each mail and HTML problem Tobey Microsoft Outlook Discussion 1 11th Nov 2009 02:44 PM
Access 2003 mail merge fails to recognise a mail merge document. ColinD Microsoft Access 1 18th Mar 2008 03:33 PM
Mail Merge Problem =?Utf-8?B?V2lsbGlhbTUyNzE=?= Microsoft Word Document Management 3 18th Jul 2007 07:14 AM
Mail-Merge: Can we have master detail relationship or multiple entities in word Mail-Merge? gmax2006 Microsoft Word Document Management 1 28th Mar 2007 07:28 PM
Insert Merge Field problem with Word-Mail Merge from Excel documen =?Utf-8?B?QXVndXN0YSBFLg==?= Microsoft Word Document Management 2 20th Jun 2005 11:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:29 PM.