Hi Cindy,
Thank you for helping me navigate the Word world.
It is not such a jungle, but I do not work enough with Word
to keep current.
"When you do a mail merge using Access as data source
another instance of Access is opened but not closed when
done."
This is only a problem if you use a DDE connection. You
might want to consider an ODBC connection, instead, which
would save the convert-to-text-file step.
I feel safer using the text file approach. The application runs on a
network of NT4 systems where things seem to change without
warning, and where NT sometimes seems to have a mind of it's
own. For example, on some machines a file that is opened then
flushed and closed can not be accessed since NT insists that
it is opened exclusively by another user.
The text file approach is quick enough and reliable, we are only
talking about two records, the column names and the data.
Now, on learning that you're dealing with a text file, I
have to wonder exactly WHICH dialog box you're dealing
with, here? Is it the one about confirming the field
delimiters? Or something else?
It is a dialog to to confirm the data source as being the text file.
I have seen it once before with another application where I had used
Word 2000 on my development machine and one user had
Office XP. I found that I could fix the problem by setting the
SubType parameter for the MailMerge.OpenDataSource
method that told Word to behave like Word 2000..
A tip, here (has nothing to do with your problem, but will
speed things up and make them more reliable):
If (rngDoc.Bookmarks.Exists("FileSpec") = True) Then
rngDoc.Bookmarks("FileSpec").Select
objWord.Selection.Text = _
strDocFilePath & "\" & strDocFileName
Use this instead to put the data into a bookmark:
rngDoc.Bookmarks("FileSpec").Range.Text = szString
Thank you, I am never sure when to use the Range and when
to use the Selection. I have the impression that Range is the
preferred way of referring to a part of a document, but I am
not always sure what the Range includes. I think I have also
found that there are situations where Range can not be used..
Your OpenDataSource statement appears rather "sparse" to
me. This may be what's causing a dialog box to appear (if
we're not talking about the delimiter one).
.OpenDataSource NAME:=strTextFilePath & "\" & FileName
There are a lot more arguments to this method than just
Name. Quite a few are unnecessary, but others help Word to
understand which connection method it should use. I suggest
you record a macro in the Word UI linking to the data
source and bring that over into your code, see if it helps
at all.
I will try that, I am having some problems with my current
Office setup, the Object Browser do not open the asssociated
help file so I am stuck with using my MSDN CD's which are
not up to date. I was no able to get a detailed list of all the
arguments with a desciption of what each argument does.
Note that you also want to do this if you decide to go the
ODBC connection-to-Access route. In order to see/set which
connection method to be used in a merge in the UI, activate
the "Select Method" checkbox in the OpenDataSource dialog
box. You should then get a list.
I assume you mean while setting it up? The user just wants to
click a button and be done with it, they prefer not to have to
respond to any dialogs, which is why I startted this thread.
Oh, and a question for you: what are the chances that this
same application will be upgraded to Word 2002 or later?
The person responsible for the overall IT situation says he is
planning to convert all machines to Windows 2000 and to
upgrade Office, in which case I think he would have to go to
either Office 2000 or Office XP.
I hesitate to make any changes because the application It
has been upgraded, started out as an Access 2 app using
strictly macros. Since then it has been converted to 95,
then 97 but most of the functionality is still in macros. This
make it very difficult and cumbersome to figure out how
the thing works (Or is supposed to work).
The guy who wrote it was the owner of the company and
he was learning on the job, this being his first Access
application, so the design is not always logical.
I will cross that bridge when I get to it. The conversion
will probably go smoothly but I would want the client to
sign of on any extra effort needed to deal with conversion
issues. before going ahead.
Take care,
Ragnar