P
Peter Danes
I'm starting a new database for the geological department in our museum. It'
s still in the pencil and paper, discussion and design stage. It will track
both publications and actual specimens, so the main structure will be a
many-to-many relationship. (One publication may talk about several rocks,
one rock may be mentioned in several publications.)
The linking table in the middle of the one-to-many-to-one will also have an
offshoot, a set of Excel workbooks. One of the properties of the members of
BOTH main relations is a set of analyses. Either, both or neither
(publications and rocks) may have one or more analyses attached. Each
analysis is essentially a table of numbers listing proportions of components
of a particular specimen. I don't want to embed the workbooks in the
database, for two reasons - database bloat and the desirability of being
able to mess with the analyses directly from Excel, without starting the
database. There are many different types, X-ray, photo-spectrometry, various
chemical methods and others. Each combination of rock and/or publication
will have at most one attendant workbook, whose name will be a combination
of the unique identifiers of the publication and/or rock, and the individual
analyses will be on separate worksheets in the workbook.
So far so good (although comments on this are welcome as well). What I want
to do from the database is automate some of Excel's operations. How might
this best be accomplished? I know how to start and operate Excel from
Access, I have done similar stunts automating Word from Access. But this
time I have several asynchronous tasks I would like to accomplish.
1. When the database starts, I want to immediately start a hidden instance
of Excel, and have Excel cruise through the subfolder below the database,
which will contain all the workbooks with the analysis worksheets. Excel's
task will be to read and store the name of every worksheet in every
workbook. When this is done, the list of names will be handed to Access, so
that as the user wanders about in the database, he will immediately know
whether a particular publication or rock has an analysis, and if so, what
all kinds, without the necessity of Access looking for a workbook and
examining the worksheet names each time a record becomes current. (The
response time would be unacceptable.) But neither do I want to force the
user to wait while Excel does this. The data waiting to loaded into this
database is already fairly large (cca. 100,000 members) with the possibility
to grow considerably. What is the best method for Access to determine when
Excel is done? It is of course possible to write a file and have Access
constantly look for this file, but that seems rather crude. I would have to
put an timer on every form that the user might have open and have each form
repeatedly interrogate the disk drive until the file is found, then read in
the data and cancel the timer event on each form. It seems there should be
some way for the Excel application to notify Access directly and have Access
respond, whether the user is doing something right then or not.
2. When the user sees that there is an analysis that he might like to
examine in detail, a button on the Access form (labeled "Show analysis")
will send a message to Excel that a particular workbook should be opened to
a particular worksheet and displayed to the user. I need to be able to deal
with two possibilities, one is an idling Excel process, possibly the same
one that read in all the names upon start-up, and the other is no Excel
running. There may have been a previous use of Excel, which the user closed
by completely closing Excel, or they may have simply Alt-Tabbed back to
Access and the Excel process is still there. I know how to deal with both
those possibilities, but again, I need to communicate between the two
processes. This time, I need Access to tell the Excel process something. If
I was starting a new process each time, there are command line parameters
that may be used, but how do I pass information to an already running
process?
Pete
----------------------------------------------------------
(This e-mail address is fake, to keep spammers and their auto-harvesters out
of my hair. If you want to get in touch personally, I am 'pdanes' and I use
yahoo mail. But please use the newsgroups whenever possible, so that all may
benefit from the exchange of ideas).
s still in the pencil and paper, discussion and design stage. It will track
both publications and actual specimens, so the main structure will be a
many-to-many relationship. (One publication may talk about several rocks,
one rock may be mentioned in several publications.)
The linking table in the middle of the one-to-many-to-one will also have an
offshoot, a set of Excel workbooks. One of the properties of the members of
BOTH main relations is a set of analyses. Either, both or neither
(publications and rocks) may have one or more analyses attached. Each
analysis is essentially a table of numbers listing proportions of components
of a particular specimen. I don't want to embed the workbooks in the
database, for two reasons - database bloat and the desirability of being
able to mess with the analyses directly from Excel, without starting the
database. There are many different types, X-ray, photo-spectrometry, various
chemical methods and others. Each combination of rock and/or publication
will have at most one attendant workbook, whose name will be a combination
of the unique identifiers of the publication and/or rock, and the individual
analyses will be on separate worksheets in the workbook.
So far so good (although comments on this are welcome as well). What I want
to do from the database is automate some of Excel's operations. How might
this best be accomplished? I know how to start and operate Excel from
Access, I have done similar stunts automating Word from Access. But this
time I have several asynchronous tasks I would like to accomplish.
1. When the database starts, I want to immediately start a hidden instance
of Excel, and have Excel cruise through the subfolder below the database,
which will contain all the workbooks with the analysis worksheets. Excel's
task will be to read and store the name of every worksheet in every
workbook. When this is done, the list of names will be handed to Access, so
that as the user wanders about in the database, he will immediately know
whether a particular publication or rock has an analysis, and if so, what
all kinds, without the necessity of Access looking for a workbook and
examining the worksheet names each time a record becomes current. (The
response time would be unacceptable.) But neither do I want to force the
user to wait while Excel does this. The data waiting to loaded into this
database is already fairly large (cca. 100,000 members) with the possibility
to grow considerably. What is the best method for Access to determine when
Excel is done? It is of course possible to write a file and have Access
constantly look for this file, but that seems rather crude. I would have to
put an timer on every form that the user might have open and have each form
repeatedly interrogate the disk drive until the file is found, then read in
the data and cancel the timer event on each form. It seems there should be
some way for the Excel application to notify Access directly and have Access
respond, whether the user is doing something right then or not.
2. When the user sees that there is an analysis that he might like to
examine in detail, a button on the Access form (labeled "Show analysis")
will send a message to Excel that a particular workbook should be opened to
a particular worksheet and displayed to the user. I need to be able to deal
with two possibilities, one is an idling Excel process, possibly the same
one that read in all the names upon start-up, and the other is no Excel
running. There may have been a previous use of Excel, which the user closed
by completely closing Excel, or they may have simply Alt-Tabbed back to
Access and the Excel process is still there. I know how to deal with both
those possibilities, but again, I need to communicate between the two
processes. This time, I need Access to tell the Excel process something. If
I was starting a new process each time, there are command line parameters
that may be used, but how do I pass information to an already running
process?
Pete
----------------------------------------------------------
(This e-mail address is fake, to keep spammers and their auto-harvesters out
of my hair. If you want to get in touch personally, I am 'pdanes' and I use
yahoo mail. But please use the newsgroups whenever possible, so that all may
benefit from the exchange of ideas).