A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Office 2007 & ODBC



 
 
Thread Tools Display Modes
  #1  
Old July 31st, 2009, 09:38 PM posted to microsoft.public.word.mailmerge.fields
JWhitehead
external usenet poster
 
Posts: 23
Default Office 2007 & ODBC

I am trying to do a mail merge in MS Word 2007 from an ODBC source. I am able
to find the option to do so. I go through this, but when I get the end, it
tells me there is errors with the merge, and no data is showing from the
merge.

If I import the data from ODBC to Access, for example, it shows all 450
records correctly. I can then do the mail merge in Word from there. The only
thing is, if the data that I've imported into Access changes in the original
table(s), other than re-importing, how would I get it to show the updated
data?

I guess what I'm asking here...
Is there a way to do a mail merge in MS Word 2007 to an ODBC source, and
actually be able to view the records?
  #2  
Old July 31st, 2009, 10:05 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Office 2007 & ODBC

1. What is the data source?

2. Do you have Word 2007 SP2, or an earlier version of Word 2007?

3. Are you using Vista-64 bit, or perhaps another 64-bit version of Windows?

As far as point (2) is concerned, currently I only have Word 2007 Sp2 to
experiment with, and when I attempted an ODBC connection with Excel,
although the connection appeared to work fine, subsequent investigation
suggests that although it is an ODBC connection, Word is not going to
tell us what the connection string is.

Peter Jamieson

http://tips.pjmsn.me.uk

JWhitehead wrote:
I am trying to do a mail merge in MS Word 2007 from an ODBC source. I am able
to find the option to do so. I go through this, but when I get the end, it
tells me there is errors with the merge, and no data is showing from the
merge.

If I import the data from ODBC to Access, for example, it shows all 450
records correctly. I can then do the mail merge in Word from there. The only
thing is, if the data that I've imported into Access changes in the original
table(s), other than re-importing, how would I get it to show the updated
data?

I guess what I'm asking here...
Is there a way to do a mail merge in MS Word 2007 to an ODBC source, and
actually be able to view the records?

  #3  
Old July 31st, 2009, 10:06 PM posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default Office 2007 & ODBC

Can you link to the original table in Access?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"JWhitehead" wrote in message
...
I am trying to do a mail merge in MS Word 2007 from an ODBC source. I am
able
to find the option to do so. I go through this, but when I get the end, it
tells me there is errors with the merge, and no data is showing from the
merge.

If I import the data from ODBC to Access, for example, it shows all 450
records correctly. I can then do the mail merge in Word from there. The
only
thing is, if the data that I've imported into Access changes in the
original
table(s), other than re-importing, how would I get it to show the updated
data?

I guess what I'm asking here...
Is there a way to do a mail merge in MS Word 2007 to an ODBC source, and
actually be able to view the records?


  #4  
Old August 4th, 2009, 01:50 PM posted to microsoft.public.word.mailmerge.fields
JWhitehead
external usenet poster
 
Posts: 23
Default Office 2007 & ODBC

Yes. I can link to the orig in Access, and it shows the data. Just don't
think should have to link the table in access to do a mail merge in word when
it shows the option as available, and we were able to link it to an ODBC in
prev version of word.

"Doug Robbins - Word MVP" wrote:

Can you link to the original table in Access?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"JWhitehead" wrote in message
...
I am trying to do a mail merge in MS Word 2007 from an ODBC source. I am
able
to find the option to do so. I go through this, but when I get the end, it
tells me there is errors with the merge, and no data is showing from the
merge.

If I import the data from ODBC to Access, for example, it shows all 450
records correctly. I can then do the mail merge in Word from there. The
only
thing is, if the data that I've imported into Access changes in the
original
table(s), other than re-importing, how would I get it to show the updated
data?

I guess what I'm asking here...
Is there a way to do a mail merge in MS Word 2007 to an ODBC source, and
actually be able to view the records?



  #5  
Old August 4th, 2009, 02:08 PM posted to microsoft.public.word.mailmerge.fields
JWhitehead
external usenet poster
 
Posts: 23
Default Office 2007 & ODBC

1. The data source is w/in sage (our finance program).

2. Word 2007 w/ SP2

3. Windows Vista, 32-bit

If I pull the data into either Excel or Access, and then create the mail
merge in word using that as the data source it works no troubles. Just can't
seem to get it to work with the ODBC.

"Peter Jamieson" wrote:

1. What is the data source?

2. Do you have Word 2007 SP2, or an earlier version of Word 2007?

3. Are you using Vista-64 bit, or perhaps another 64-bit version of Windows?

As far as point (2) is concerned, currently I only have Word 2007 Sp2 to
experiment with, and when I attempted an ODBC connection with Excel,
although the connection appeared to work fine, subsequent investigation
suggests that although it is an ODBC connection, Word is not going to
tell us what the connection string is.

Peter Jamieson

http://tips.pjmsn.me.uk

JWhitehead wrote:
I am trying to do a mail merge in MS Word 2007 from an ODBC source. I am able
to find the option to do so. I go through this, but when I get the end, it
tells me there is errors with the merge, and no data is showing from the
merge.

If I import the data from ODBC to Access, for example, it shows all 450
records correctly. I can then do the mail merge in Word from there. The only
thing is, if the data that I've imported into Access changes in the original
table(s), other than re-importing, how would I get it to show the updated
data?

I guess what I'm asking here...
Is there a way to do a mail merge in MS Word 2007 to an ODBC source, and
actually be able to view the records?


  #6  
Old August 4th, 2009, 03:23 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default Office 2007 & ODBC

I suspect you're going to have to use some VBA.

The problem I had earlier was that I could make an ODBC connection, but
then Word would not re-open it (it didn't even issue the usual "SQL"
prompt) when you saved/closed/re-opened your mail merge main document.
So I couldn't be sure what connection string Word was actually using.

However, the reason why Word will not re-open is typically because it
expects the data source to have a "file name", and when you open using a
machine ODBC DSN (i.e. user or system DSN), there is no file name. it is
possible that a similar problem is preventing Word from seeing your data
source correctly. This used to be OK in previous versions of Word but no
longer works in Word 2007 - I think it's actually an accidental change
rather than a deliberate attempt to scupper ODBC connections.

So I tried using a file DSN. Unfortunately, Word doesn't really like
them either so I don't think you can open them purely using the standard
Word user interface.

However, you do seem to be able to open using a file DSN using Word VBA
and an OpenDataSource statement. And in fact the "file DSN" doesn't even
need to be a real .dsn file. It can be a completely empty file that you
create in Notepad. You can provide completely different connection
information in the connection parameter. But you have to know what that
connection information should be.

For example, here's the VBA I was using with an empty excel.dsn

Sub ConnectViaEmptyFileDSN()
With ActiveDocument.MailMerge
' the following statement disconnects
' any existing source
.MainDocumentType = wdNotAMergeDocument
.OpenDataSource _
Name:="C:\Users\username\Documents\My Data Sources\excel.dsn", _
connection:="DSN=Excel
Files;DBQ=C:\mywbs\test.xls;DriverId=1046;MaxBuffe rSize=2048;PageTimeout=5;",
_
sqlstatement:="SELECT * FROM `Sheet1$`", _
SubType:=wdMergeSubTypeWord2000
End With
End Sub

In the above,
a. the Name parameter is set to the pathname of the (empty) .dsn
b. the connection string references a /user/ DSN (not a file DSN)
called "Excel Files". You presumably have a DSN that you use to connect
to Sage, and you would use that name instead. The rest of the connection
string contains values that would either typically be stored in the User
DSN anyway, such as MaxBufferSize, or values that are unique to this
connection - in this case

DBQ specifies the path name of the .xls file.

c. In your case, I don't know what would need to go in the
sqlstatement parameter, but it would probably be a simple "SELECT * FROM
[something]"



Alternatively, if you have a File DSN for your data source, you should
be able to do:

Sub ConnectViaCompleteFileDSN()
With ActiveDocument.MailMerge
' the following statement disconnects
' any existing source
.MainDocumentType = wdNotAMergeDocument
.OpenDataSource _
Name:="C:\Users\username\Documents\My Data Sources\excel.dsn", _
connection:="FILEDSN=C:\Users\username\Documents\M y Data
Sources\excel.dsn", _
sqlstatement:="SELECT * FROM `Sheet1$`", _
SubType:=wdMergeSubTypeWord2000
End With
End Sub

In other words, the same file is referenced by the Name parameter and
the FILEDSN keyword.

There are other "mix 'n' match" possibilities I think.

Not very nice but once you have set up your data source, Word /may/
reconnect to it when it re-opens the mail merge main document, and that
may be worth having.

If it works at all for /your/ data source, that is, and unfortunately as
I don't have Sage here I can't experiment.

Peter Jamieson

http://tips.pjmsn.me.uk

JWhitehead wrote:
1. The data source is w/in sage (our finance program).

2. Word 2007 w/ SP2

3. Windows Vista, 32-bit

If I pull the data into either Excel or Access, and then create the mail
merge in word using that as the data source it works no troubles. Just can't
seem to get it to work with the ODBC.

"Peter Jamieson" wrote:

1. What is the data source?

2. Do you have Word 2007 SP2, or an earlier version of Word 2007?

3. Are you using Vista-64 bit, or perhaps another 64-bit version of Windows?

As far as point (2) is concerned, currently I only have Word 2007 Sp2 to
experiment with, and when I attempted an ODBC connection with Excel,
although the connection appeared to work fine, subsequent investigation
suggests that although it is an ODBC connection, Word is not going to
tell us what the connection string is.

Peter Jamieson

http://tips.pjmsn.me.uk

JWhitehead wrote:
I am trying to do a mail merge in MS Word 2007 from an ODBC source. I am able
to find the option to do so. I go through this, but when I get the end, it
tells me there is errors with the merge, and no data is showing from the
merge.

If I import the data from ODBC to Access, for example, it shows all 450
records correctly. I can then do the mail merge in Word from there. The only
thing is, if the data that I've imported into Access changes in the original
table(s), other than re-importing, how would I get it to show the updated
data?

I guess what I'm asking here...
Is there a way to do a mail merge in MS Word 2007 to an ODBC source, and
actually be able to view the records?

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:34 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.