I have an Excel application that makes EXTENSIVE use of VBA macros.
(Two files have a little over 11,000 lines of code, with not NEARLY
enough comments!)
Now, this application makes use of some (7) data files that are
generated by another application that I have no control over.
One file reads in the data and does some compilation, formatting, and
generates a report that is posted in a shared folder. Then, the
second file "kicks in" and extracts a subset of data from the shared
file and generates a report that is posted for yet another audience.
The whole process takes a little over an hour to execute manually.
(which is a HUGE savings over 6-8 hours it took the way they USED to
do it before I stuck my nose in)
After 4 years, I FINALLY got the PTB (Powers That Be) to agree to
schedule a job that creates the data files every night rather than
having to do it manually. (Hooray!)
I used VBScript to create a file to control the sequencing and set it
up to run as a Scheduled Task on my workstation. If I can get this
to run smoothly, I'll actually be able to take a vacation that
includes a Friday in which I don't call in and walk someone through
the steps to update the reports!
The whole job seems to run smoothly.
However, I've discovered that some of the data collected in the first
file may be incomplete, or in error.
Now, that doesn't affect the first report (because that's one of the
things I'm REPORTING) but, if one of these errors occur, I want to
skip the second report.
Now, I use the VBA method: Application.Quit to exit Excel and return
control to the VBScript, but I don't have any control over
the "return" code.
As in: RetVal = WshShell.Run ("Appname.xls",1,true)
RetVal always has 0...
I realize I can have the first Excel VBA "Call" the second Excel file,
but there are some socio-political reasons why I'm being asked NOT to
do it this way (the files are on different servers, and never-the-
twain-shall-meet kind-of thing)
so.. After all of that, the question is:
Does anyone know how to force VBA to issue a return value when
exiting either the file or excel?
My other option is to use VBS to search through 60,000 lines of text
in the data files and determine if any of the "suspect" data is
present before launching the second process, but that's undesireable
for a LOT of reasons.
any thoughts?