Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Leuven, Vlaanderen, Belgium
    Thanked 0 Times in 0 Posts

    Word won't print at other pc (Access/Word 97)

    Valuable members of this board,

    I use Access VBA automation for printing a few thousands of Word documents.
    You find the database attached + a separate txt-file with the procedure (module - procedure FindReplace)): I've put '=========== lines before & after the code lines in question.
    This worked great on my pc untill I got a 'blue screen' several times... Having no time to figure out why, I "quickly"' turned to a collegue's pc, installed the necessary driver, moved the Access database over there, repaired & compacted, checked the VBA references.

    Problem: the procedure runs without an error but the Word print command doesn't execute while the Word instance (invisible) doesn't close, so remains open.
    What may have gone wrong?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Word won't print at other pc (Access/Word 97)

    The procedure has several problems:

    - You set "On Error Resume Next" at the beginning; this is needed to avoid problems if Word is not running, but you should set "On Error GoTo 0" or even better "On Error GoTo ErrorHandler" where ErrorHandler is a label after setting appWord. The way it is now, you'll never be warned if an error occurs.

    - You repeatedly use GetObject / New Word.Application within the loop. You already set appWord before the loop, so there is no need to do it within the loop.

    - You also shouldn't set appWord to Nothing within the loop, but afterwards.

    - You should quit Word at the end if you started it at the beginning:

    Dim blnStartWord As Boolean
    Set appWord = GetObject(, "Word.Application")
    If Err = 429 Then
    Set appWord = New Word.Application
    blnStartWord = True
    End If
    On Error Goto 0

    At the end:

    If blnStartWord = True Then
    End If
    Set appWord = Nothing

Posting Permissions

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