Can I tell whether Access was opened by Word?

  • Thread starter Thread starter InvisibleDuncan
  • Start date Start date
I

InvisibleDuncan

I have an Access 97 database that has an autoexec macro that runs every time
it's opened. However, it's also running every time my users open a Word
document that has a mail-merge from the database. Is there a way for Access
to know that it's been opened by Word and therefore not run the Autoexec
macro?

Thanks...
 
hi,

I have an Access 97 database that has an autoexec macro that runs every time
it's opened. However, it's also running every time my users open a Word
document that has a mail-merge from the database.
The AutoExec macro should only be run when the database is opened in
Access. A normal mail-merge should only read data from the database file.
Is there a way for Access
to know that it's been opened by Word and therefore not run the Autoexec
macro?
No.

I would consider creating a second front-end for the mail-merge without
AutoExec macro.


mfG
--> stefan <--
 
InvisibleDuncan said:
I have an Access 97 database that has an autoexec macro that runs every
time
it's opened. However, it's also running every time my users open a Word
document that has a mail-merge from the database. Is there a way for
Access
to know that it's been opened by Word and therefore not run the Autoexec
macro?

If you are explicitly starting Access from Word, you could use a
command-line parameter and have your AutoExec macro quit based on the
command line parameter value. Here's an example from a command file I've
used to start Access:
Start "MyWindowTitle" "C:\MyFolder\MyDB.mdb" "/cmd: /ReadOnlyForms"
 
Stefan Hoffmann said:
The AutoExec macro should only be run when the database is opened in
Access. A normal mail-merge should only read data from the database file.

That's what I would have thought. As far as I'm aware it's just a standard
mail-merge - we certainly haven't done anything fancy - but it actually
opens an instance of Access alongside Word.
 
Paul Shapiro said:
If you are explicitly starting Access from Word, you could use a
command-line parameter and have your AutoExec macro quit based on the
command line parameter value. Here's an example from a command file I've
used to start Access:
Start "MyWindowTitle" "C:\MyFolder\MyDB.mdb" "/cmd: /ReadOnlyForms"
Unfortunately, we don't explicitly open the database - we just use Word's
built-in mail-merge functionality. There doesn't seem to be any scope in
there for using command line switches.
 
If I remember correctly, Word has three (?) different
methods for doing mail merge. In order of invention,
they were

DDE (Access 2)
ODBC (Access 95)
OLEDB (Access 2000)

Of these, only DDE normally opens Access and runs an
autoexec macro. (unless there is some new problem in
some new version of Office).

So one way might be to change your mail merge document
to merge using ODBC rather than DDE.

Another way would be to create a new database for
mail merge which only contains links to the tables in
your real database, (or links to the queries, or queries
linked to the tables, or queries linked to the queries)

You create a database of table links by importing the
tables as links. You create linked queries by specifying
the table (or query) and database in a query definition.


(david)
 
Thanks, David - that's very helpful. Believe it or not I'm using Word and
Access 97, so that might explain why it's happening. Do you know how to get
the document to use ODBC instead of DDE? I'm simply using the default setting
that comes from the mail-merge wizard in Word, and there doesn't seem to be
an obvious way of stopping it from using DDE.

Thanks,
 
I think you have to tell Word not to automatically connect
to the mail merge source. That is, choose "select" as the
mail merge source type.

Then when you start to mail merge, Word will ask you for
the source, and you can select an ODBC driver or DSN
you have set up.

Or I think you can automate this process using VBA.

I don't have an examples at hand.

(david)
 
Back
Top