Results 1 to 2 of 2
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Yilgarn region of Toronto, Ontario
    Thanked 0 Times in 0 Posts

    Running Long Jobs (Office XP)

    I run long jobs. Applications written in, say, Word/VBA to process 20,000 files or documents at a time. The process is iterative, and MSWord being what it is, it will crash from time to time. I needed a way to monitor what's going on without sitting in front of the computer. In particular, when a client requests that I set up a dozen computers to process chunks of the job in parallel batches, the client wants a way of knowing that all is running well in the boardroom, or at least, needs to know that they'll hear a cry for help should the process lock up.

    Word can't notify anyone if it locks up. With Word6 and its infamous "Out Of memory" I resorted to re-booting every 100 documents, having WFWG AutoExec.bat check if the timestamp had changed on the table of files, and if it had changed, firing up Word for another 100 documents, reboot etc. Today that's not an option. And anyway, it doesn't seem right to interrupt a job that's running so that I can reboot the computer.

    I decided that I'd write an application to monitor Word, and to issue an alarm should activity cease.

    The iterative Word application This is just a loop through a set of files. The application is given a string array of file names, and loops using "lng" as an index to the array. Every tenth loop, I write the value of lng to an INI file, and can use that value as a restart point. Of course, at that time I could play a WAV file "All's well" or similar, for re-assurance that it's bopping along. But I'm more concerned with hearing when it is NOT bopping along. Every 10th loop, I write to a disk file.

    The monitoring process (Attached) This is written in Excel/VBA. The workbook, when opened, starts a loop with a macro that checks to see that the Word Application's INI file has changed (by checking the time stamp), and if the Word application has NOT changed the INI file, the Excel application issues an alarm - a WAV file, of course, which I will hear. If I'm running this at home, I could set the Word application to silent running (no WAV file to be issued every ten files), crank up the volume for the Excel WAV file, and go sleep in bed all day long.

    Parameters The Excel application needs an INI file or similar with three keys:
    TestFile=C:GreavesProductsUSERFilesWorkedExamplesW orkEx.INI</pre>

    "SoundFile" is the name of the WAV file to be played when a dearth of activity is detected.
    "Delay" is the time limit beyond which we suspect the Word appliaction has died.
    "TestFile" is the file whose timestamp we will check.

    You can see by the above sample from an Excel Checker.INI that I'm testing the WorkEx.INI file every five minutes. If its timestamp does NOT change from one five minute sampling to the next, Rowan Atkinson will stentor "If you want something done properly, Kill Baldric first!". I could have used the TextToSpeech and have the sound card speak out a text message, I suppose. I chose an audible alarm. I could have elected to send an email message to the client's downtown office saying "Tell Chris to get the subway home; the job is stalled". (Or I could buy a laptop and take it with me!). These settings suggest that i should be processing ten files in less than five minutes.

    The Excel application includes in its Initialization routine:
    <pre> strSoundFileName = GetINIValue("SoundFileName")
    strDelay = GetINIValue("Delay")
    strTestFile = GetINIValue("TestFile")</pre>

    The Word Application needs an INI file or similar with three keys:
    Checker=C:GreavesProductsUSERFilesWorkedExamplesCh ecker.xls

    "RestartPointSEQFields" is the value of lng written out every 10 loops
    "Checker" is the name of the Excel/VBA application with an auto-start event.
    "CheckEvery" is the sampling interval in the loop.

    During the Word application Initialization, it fires up Checker: <pre> strChecker = GetINIValue("Checker")
    Dim oItem As Object
    Dim objApp As New Excel.Application
    objApp.Visible = True
    objApp.Workbooks.Open (strChecker )</pre>

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Yilgarn region of Toronto, Ontario
    Thanked 0 Times in 0 Posts

    Re: Running Long Jobs (Office XP)

    The conversion filters in WordXP are to be despised. The filters in Word97 are simpler and satisfactory, so I'm converting a motley collection of files from WP51DOS, WPWin, Word, RTF, HTM etc into Word97 format, after which I'll clean them up in WordXP.

    The job to read and save-as-Word suffers frequent interruptions, mostly in the form of untrappable errors. These errors are reported by the 3rd-party conversion routines, examples are (paraphrased) "This document appears to be corrupt. Continue?" and "I can't find the graphic *.WPG; you want to go look for it?", and similar. All such messages throw up a MsgBox item and hang there waiting for me to do something.

    My solution is to introduce two support files to the conversion process: I have a hit-list of files to avoid, stored in a file AVOID.TXT, and I write the file I'm about to (try to) convert to INCOMING.TXT. The Word97 batch job locates its files, loads an avoidance array from AVOID.TXT, and loops, writing the next file name to INCOMING.TXT and opening that file. The converter may hang, as described above, but not before writing the offender's name to INCOMING.TXT.

    The Word batch job is set as a shortcut in Win98's Startup folder, along with a shortcut to Monitor.XLS. (in the attached PKZIP25 file)

    Monitor's job is to check the timestamp on INCOMING.TXT every one minute. If the timestamp is unchanged, Monitor appends the contents of INCOMING.TXT to AVOID.TXT, and reboots the system.

    When Word re-boots, it hangs, of course "This document appears to be corrupted. Attempt recovery now?", but I'm not there; I'm fast asleep in bed. After one minute, Monitor.XLS reboots, and on the second reboot, the corruption condition is flushed, and the Word application continues processing files.

    It's not as good as continual running, but it does allow me to set the machine running and walk away. At the end of the whole run, I'm left with a list of awkward files, and it's OK to sit and nurse those through by hand. If I'm billing extra for awkward files, so much the better.

    For some reason, firing up the XLS from within Word doesn't seem to work; it's as if the Application.OnTime knows that it came from Word, and Word is hung, so I'll just wait a while longer. Starting the XLS from the Windows Startup folder works perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts