run-time error '5922' and csv files

D

Dominic Godin

Hi,

I have a macro in a word template that falls over with this code.

'Set object reference to this mail merge (convenience coding)
Set thisMerge = ThisDocument.MailMerge

'Setup the mail merge datasource
With thisMerge
'Set the merge type
.MainDocumentType = wdFormLetters
'Set the data source information. Falls over here!!
.OpenDataSource name:= "C:\Temp\batchmerge.csv"
.SuppressBlankLines = True
.execute
End With

The file batchmerge does exist and isn't corrupt. This works for most
of our clients. The client it falls over on is using metaframe and word
2000. I get the error can not open data source. Is this due to ODBC
settings or something. I know little about metaframe but our engineer
says that the user can see C:\Temp\batchmerge.csv.

Any ideas??

Dominic Godin
 
C

Cindy M -WordMVP-

Hi Dominic,

When picking up a text file in Word 2000 (note _2000_, not 2002 or 2003 -
this is important!), Word has the choice of using ODBC or its internal text
converter. Given your macro code, I'd assume Word will try to use the text
converter (you don't specify a DSN or anything of that sort). That should
be present on every machine and not cause a problem. OTOH, I don't know
anything about metaframe, either, so I don't know how/whether it might be
interfering.

The first thing I'd test, is whether this file can be opened in the UI. If
it can, then someone should record a macro while doing so, so that you can
compare the OpenDataSource code and see what kind of connection Word
"wants" to use.

My personal feeling is that this metaframe may somehow be blocking Word's
access to the external file.
'Set object reference to this mail merge (convenience coding)
Set thisMerge = ThisDocument.MailMerge

'Setup the mail merge datasource
With thisMerge
'Set the merge type
.MainDocumentType = wdFormLetters
'Set the data source information. Falls over here!!
.OpenDataSource name:= "C:\Temp\batchmerge.csv"
.SuppressBlankLines = True
.execute
End With

The file batchmerge does exist and isn't corrupt. This works for most
of our clients. The client it falls over on is using metaframe and word
2000. I get the error can not open data source. Is this due to ODBC
settings or something. I know little about metaframe but our engineer
says that the user can see C:\Temp\batchmerge.csv.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
D

Dominic Godin

Thanks for the reply.

I managed to fix it in the end. Apparently Word has some nasty bugs
with certain versions of the ODBC. I switched the file extension from
csv to dat so word wouldn't use the ODBC and now all works fine.

Thanks

Dominic Godin
 
C

Cindy M -WordMVP-

Hi Dominic,
I managed to fix it in the end. Apparently Word has some nasty bugs
with certain versions of the ODBC. I switched the file extension from
csv to dat so word wouldn't use the ODBC and now all works fine.
OK, thanks for letting me know. From your code, it didn't look like Word
was making an ODBC connection (no DSN mentioned), which is why I didn't
follow that track.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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