Results 1 to 1 of 1
  1. #1
    sabbo64 is offline Novice
    Windows XP Access 2000
    Join Date
    Aug 2009
    Posts
    3

    Thumbs down Multiple Mailmerge documents

    After overcoming my previous difficulties, I now have another one to contend with. My routine uses three queries to get data from the data base before maimerging the info to print out in word. When step through the application all works fine, however, when I leave the module to its own devices a problem occurs. The first letter prints off without trouble, however between printing the second and third letters word seems to hang for a bit before the Access Logon prompt appears. OK-ing the logon prompt continues the application without any further problems.

    Also, if I surround the word app "CreateObject" line with message box objects e.g.

    MsgBox "Start of letter no " & LetterNo & " create word app"
    Set objWord = CreateObject("word.application")
    MsgBox "End of letter no " & LetterNo & " create word app"

    the routine works OK allbeit that I have some message boxes to respond to

    Any suggestions?

    code as follows:

    Public Sub PrintReminders(LetterNo As Integer)
    Dim objWordDoc As Word.Document
    Dim objWord As Word.Application
    Dim strFilePath As String
    Select Case LetterNo
    Case 1
    strFilePath = "C:\Documents and Settings\sbny3190\My Documents\A Licences\MailTest1.doc"
    strQuery = "qry_Reminder1"
    Case 2
    strFilePath = "C:\Documents and Settings\sbny3190\My Documents\A Licences\MailTest2.doc"
    strQuery = "qry_Reminder2"
    Case 3
    strFilePath = "C:\Documents and Settings\sbny3190\My Documents\A Licences\MailTest3.doc"
    strQuery = "qry_Reminder3"
    End Select
    On Error GoTo Err_cmd_Reminders_Click
    If CheckRecordCount Then
    DoCmd.SetWarnings False
    Set objWord = CreateObject("word.application")
    Set objWordDoc = objWord.Documents.Open(strFilePath)
    objWord.ActiveDocument.MailMerge.Execute
    With objWord.Application
    .DisplayAlerts = wdAlertsNone
    .Visible = True
    .Options.PrintBackground = False
    With .ActiveDocument
    .PrintOut
    .Close wdDoNotSaveChanges
    End With
    End With
    DoCmd.SetWarnings True
    UpdateCorrespondence (LetterNo)

    Exit_cmd_Reminders_Click:
    objWord.Application.Quit wdDoNotSaveChanges


    End If
    Set objWordDoc = Nothing
    Set objWord = Nothing
    Exit Sub
    Err_cmd_Reminders_Click:
    MsgBox Err.Description
    Resume Exit_cmd_Reminders_Click
    End Sub


    Called from a command button:-

    Private Sub cmd_Reminders_Click()
    On Error GoTo ErrorHandler
    'Print letters in reverse order so that updates can be applied
    PrintLetters.PrintReminders (3)
    PrintLetters.PrintReminders (2)
    PrintLetters.PrintReminders (1)
    MsgBox "Reminder letters have been printed", vbInformation + vbOKOnly

    ErrorExit:
    Exit Sub

    ErrorHandler:
    Err.Number = Err.Number + 1000
    MsgBox Err.Description
    Resume ErrorExit
    End Sub
    Last edited by sabbo64; 09-05-2009 at 05:10 AM. Reason: More info

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Categorizing Word documents with Access
    By radagast in forum Access
    Replies: 0
    Last Post: 06-14-2009, 12:06 AM
  2. Mailmerge Current Record...
    By oakleyp2 in forum Programming
    Replies: 0
    Last Post: 02-22-2006, 08:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums