Email Mail Merge from Access 2003

D

DennisB

Hi

I am trying to start a Word email mailmerge from Access 2003 by clicking a
command button macro.

I have a module containing the Mergit () function.

The macro uses "OpenModule" to call the function.

The function contains this code:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\CPS\Letters\EMember Newsletter Notification",
"Word Document")
'Make Word Visible.
objWord.Application.Visible -True
'Set the mail merge data source as CPS.
objWord.MailMerge.OpenDataSource _
Name:="C:\CPS\CPS Source\CPS.mdb", _
LinkToSource:=True, _
Connection:="QUERY Active EMembers", _
SQLStatement:="SELECT * FROM [Active EMembers]"
objWord.MailMerge.Execute
End Function

All that happens is that the Module opens for editing.

Can someone tell me where I'm being stupid?

Thanks

Dennis
 
T

Tom van Stiphout

On Mon, 17 Dec 2007 07:13:03 -0800, DennisB

Change OpenModule to RunCode.
-Tom.
 
D

DennisB

Hi Tom

thanks for that - but I get an error message saying the macro action has
failed.

Anything else I could try?


--
DennisB


Tom van Stiphout said:
On Mon, 17 Dec 2007 07:13:03 -0800, DennisB

Change OpenModule to RunCode.
-Tom.

Hi

I am trying to start a Word email mailmerge from Access 2003 by clicking a
command button macro.

I have a module containing the Mergit () function.

The macro uses "OpenModule" to call the function.

The function contains this code:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\CPS\Letters\EMember Newsletter Notification",
"Word Document")
'Make Word Visible.
objWord.Application.Visible -True
'Set the mail merge data source as CPS.
objWord.MailMerge.OpenDataSource _
Name:="C:\CPS\CPS Source\CPS.mdb", _
LinkToSource:=True, _
Connection:="QUERY Active EMembers", _
SQLStatement:="SELECT * FROM [Active EMembers]"
objWord.MailMerge.Execute
End Function

All that happens is that the Module opens for editing.

Can someone tell me where I'm being stupid?

Thanks

Dennis
 
T

Tom van Stiphout

On Mon, 17 Dec 2007 10:58:00 -0800, DennisB

Yes. You should debug your function. Btw, this needs to be a public
function in a standard module. Is it?
Set a breakpoint at the top of the function and invoke it from the
Immediate window (Ctrl+G) like this:
?MergeIt()

-Tom.


Hi Tom

thanks for that - but I get an error message saying the macro action has
failed.

Anything else I could try?


--
DennisB


Tom van Stiphout said:
On Mon, 17 Dec 2007 07:13:03 -0800, DennisB

Change OpenModule to RunCode.
-Tom.

Hi

I am trying to start a Word email mailmerge from Access 2003 by clicking a
command button macro.

I have a module containing the Mergit () function.

The macro uses "OpenModule" to call the function.

The function contains this code:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\CPS\Letters\EMember Newsletter Notification",
"Word Document")
'Make Word Visible.
objWord.Application.Visible -True
'Set the mail merge data source as CPS.
objWord.MailMerge.OpenDataSource _
Name:="C:\CPS\CPS Source\CPS.mdb", _
LinkToSource:=True, _
Connection:="QUERY Active EMembers", _
SQLStatement:="SELECT * FROM [Active EMembers]"
objWord.MailMerge.Execute
End Function

All that happens is that the Module opens for editing.

Can someone tell me where I'm being stupid?

Thanks

Dennis
 

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