Reply
 
Thread Tools Display Modes
  #1   Report Post  
Robert Jones
 
Posts: n/a
Default Can I Mail Merge from SQL Database without an odc datasource?

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_Connec tion=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?


  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

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
"Robert Jones" wrote in message
...
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_Connec tion=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?




  #3   Report Post  
Robert Jones
 
Posts: n/a
Default

I've gone with the empty odc file and it appears to work fine - thanks this
is really useful.

"Peter Jamieson" wrote in message
...
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
"Robert Jones" wrote in message
...
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_Connec tion=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?






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge to a secured Access database Roger Mailmerge 2 May 5th 05 03:21 PM
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM
Mail Merge - DataPerfect database to Word DustyD Mailmerge 1 January 8th 05 09:49 AM
Problem with mail merge and works database techman Mailmerge 2 December 1st 04 04:47 PM
Word mail merge doesn't pick up the addresses in Access database. Julie Tables 1 November 24th 04 01:26 AM


All times are GMT +1. The time now is 06:24 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"