OpenDataSource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I am trying to automate Mail Merge. I understand it can be done using
vba (what can't if you only know the code!). I want to kick of mail merge
using an query (qrySol) and using an existing word document (SolLetter).

Seaching Microsoft.com, I found a snippet:

<MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc",
SQLStatement:="SELECT * FROM [MyTable]"

How can I put my query and word names into the statement (meaning, what is
my MailMergeObject name, what does Name:="C:\MyDataSource.odc" refer to?

I don't want to state a SQLStatement since my query is a SQL statement.

And once the code statement is correct, how do I kick it off within my code?

I appreciate any suggestions (details being very nice!). Thanks for your
time!
 
I'm not sure exactly what you mean by "automate".
You can set up your MailMerge in Word, and specify your database and query
as your source.
Then you can run it from Word without having to open the Access database
directly at all.

HTH
 
Thanks for the reply.
I have a command button that runs mailing labels based on a query, and I'd
like the same command button to kick off mail merge using this pre-determined
query so that I print the letters that I'll mail with the mailing labels. My
thought is that I'd get the letters and mailing labels run automatically (via
vba) instead of the users having to go into Word.

I thought <MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc"
looked promising as a way to open the mail merge object and run it via vba.
I heard that you can use vba code to run mail merge. But it seems that this
code snippet opens the mail merge obejct (if I could figure out the correct
syntax), but doesn't kick off mail merge to print off the letters based on
the query.

I'm trying to figure out how to do it automatically in vba. Thanks.


MacDermott said:
I'm not sure exactly what you mean by "automate".
You can set up your MailMerge in Word, and specify your database and query
as your source.
Then you can run it from Word without having to open the Access database
directly at all.

HTH

Stephanie said:
Hi. I am trying to automate Mail Merge. I understand it can be done using
vba (what can't if you only know the code!). I want to kick of mail merge
using an query (qrySol) and using an existing word document (SolLetter).

Seaching Microsoft.com, I found a snippet:

<MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc",
SQLStatement:="SELECT * FROM [MyTable]"

How can I put my query and word names into the statement (meaning, what is
my MailMergeObject name, what does Name:="C:\MyDataSource.odc" refer to?

I don't want to state a SQLStatement since my query is a SQL statement.

And once the code statement is correct, how do I kick it off within my code?

I appreciate any suggestions (details being very nice!). Thanks for your
time!
 
I was rather hoping another poster would jump in here -
there's someone who posts often here and has a website with an entire
MailMerge utility you can just paste wholesale into your code.
If you search this forum, I'm sure you'll find a reference to it...

Stephanie said:
Thanks for the reply.
I have a command button that runs mailing labels based on a query, and I'd
like the same command button to kick off mail merge using this pre-determined
query so that I print the letters that I'll mail with the mailing labels. My
thought is that I'd get the letters and mailing labels run automatically (via
vba) instead of the users having to go into Word.

I thought <MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc"
looked promising as a way to open the mail merge object and run it via vba.
I heard that you can use vba code to run mail merge. But it seems that this
code snippet opens the mail merge obejct (if I could figure out the correct
syntax), but doesn't kick off mail merge to print off the letters based on
the query.

I'm trying to figure out how to do it automatically in vba. Thanks.


MacDermott said:
I'm not sure exactly what you mean by "automate".
You can set up your MailMerge in Word, and specify your database and query
as your source.
Then you can run it from Word without having to open the Access database
directly at all.

HTH

Stephanie said:
Hi. I am trying to automate Mail Merge. I understand it can be done using
vba (what can't if you only know the code!). I want to kick of mail merge
using an query (qrySol) and using an existing word document (SolLetter).

Seaching Microsoft.com, I found a snippet:

<MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc",
SQLStatement:="SELECT * FROM [MyTable]"

How can I put my query and word names into the statement (meaning, what is
my MailMergeObject name, what does Name:="C:\MyDataSource.odc" refer to?

I don't want to state a SQLStatement since my query is a SQL statement.

And once the code statement is correct, how do I kick it off within my code?

I appreciate any suggestions (details being very nice!). Thanks for your
time!
 
Thanks for the tip. I suppose it helps when I search for MailMerge rather
than separate words! I think you're thinking of Albert D. Kallal. I pulled
down his sample MailMerge database and I'll give it a try.
--
Thanks for the help!

MacDermott said:
I was rather hoping another poster would jump in here -
there's someone who posts often here and has a website with an entire
MailMerge utility you can just paste wholesale into your code.
If you search this forum, I'm sure you'll find a reference to it...

Stephanie said:
Thanks for the reply.
I have a command button that runs mailing labels based on a query, and I'd
like the same command button to kick off mail merge using this pre-determined
query so that I print the letters that I'll mail with the mailing labels. My
thought is that I'd get the letters and mailing labels run automatically (via
vba) instead of the users having to go into Word.

I thought <MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc"
looked promising as a way to open the mail merge object and run it via vba.
I heard that you can use vba code to run mail merge. But it seems that this
code snippet opens the mail merge obejct (if I could figure out the correct
syntax), but doesn't kick off mail merge to print off the letters based on
the query.

I'm trying to figure out how to do it automatically in vba. Thanks.


MacDermott said:
I'm not sure exactly what you mean by "automate".
You can set up your MailMerge in Word, and specify your database and query
as your source.
Then you can run it from Word without having to open the Access database
directly at all.

HTH

Hi. I am trying to automate Mail Merge. I understand it can be done using
vba (what can't if you only know the code!). I want to kick of mail merge
using an query (qrySol) and using an existing word document (SolLetter).

Seaching Microsoft.com, I found a snippet:

<MailMergeObject>.OpenDataSource Name:="C:\MyDataSource.odc",
SQLStatement:="SELECT * FROM [MyTable]"

How can I put my query and word names into the statement (meaning, what is
my MailMergeObject name, what does Name:="C:\MyDataSource.odc" refer to?

I don't want to state a SQLStatement since my query is a SQL statement.

And once the code statement is correct, how do I kick it off within my
code?

I appreciate any suggestions (details being very nice!). Thanks for your
time!
 
Back
Top