Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / June 2005

Tip: Looking for answers? Try searching our database.

Can I Mail Merge from SQL Database without an odc datasource?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Jones - 01 Jun 2005 09:03 GMT
I want to be able to run a mail merge using data from a SQL database, but I
don't want to have to set up an odc datasource for everyone who will be
running the mail merge. I can't guarantee a shared network drive so sharing
an odc isn't an option either. If you look at the options for a mail merge:

   ActiveDocument.MailMerge.OpenDataSource Name:="Name_Address.odc" _
       , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
       AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
       WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
       Format:=wdOpenFormatAuto, Connection:= _
       "Provider=MSDASQL.1;Persist Security Info=True;Extended
Properties=""DSN=MyLetters;UID=Work;APP=Microsoft Office
2003;WSID=12345;DATABASE=MyDatabase;Trusted_Connection=Yes"";Initial
Catalog=iMIS" _
       , SQLStatement:="SELECT * FROM ""Name_Address""", SQLStatement1:="",
_
       SubType:=wdMergeSubTypeOther

it looks as if the mail merge already has all the SQL information it needs
in the Connection and SQLStatement properties. Is there a way to avoid
having to specify the odc file?
Peter Jamieson - 01 Jun 2005 10:50 GMT
Unfortunately, you have to have /something/ other than the Word document.
The something can either be a .odc, a .udl, an ODBC file dsn, or an ODBC
machine dsn (this is the only "something" that is not a file in the file
system).

However, the .odc can be a completely blank file, as long as all the
necessary connectivity and SQL information is in the OpenDataSource call. So
one approach might be to create a single "empty.odc" in a standard location
on all the machines that need one and use that for all merges that need a
.odc, or maybe you could use VBA to create a blank .odc in the same folder
as the .doc (say) before issuing the OpenDataSource call.

Peter Jamieson
>I want to be able to run a mail merge using data from a SQL database, but I
>don't want to have to set up an odc datasource for everyone who will be
[quoted text clipped - 19 lines]
> in the Connection and SQLStatement properties. Is there a way to avoid
> having to specify the odc file?
Robert Jones - 01 Jun 2005 15:27 GMT
I've gone with the empty odc file and it appears to work fine - thanks this
is really useful.

> Unfortunately, you have to have /something/ other than the Word document.
> The something can either be a .odc, a .udl, an ODBC file dsn, or an ODBC
[quoted text clipped - 34 lines]
>> needs in the Connection and SQLStatement properties. Is there a way to
>> avoid having to specify the odc file?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.