• Word wont save mailmerge data connection

    • This topic has 11 replies, 4 voices, and was last updated 16 years ago.
    Author
    Topic
    #460667

    I have several mail merge docs that I call up from Access. Access creates a new Word doc to contain the data, saves and closes that doc, then opens the mail merge doc. They have all lost their connection to the data docs. The data docs have the correct data, but the mail merge docs won’t link to them. I manually link the doc and save it, but next time the data remains unconnected. These docs have been working perfectly for years. I first noticed this a couple of months ago, but it has taken me this long to see that it happens every time. (yeah I know I’m slow).
    any ideas anyone?

    Viewing 2 reply threads
    Author
    Replies
    • #1165743

      Has the path to the data source become very long? If so, this could have caused the connection string to become too long so it would be truncated when the document is saved.

      BTW when performing a mail merge from Access, I never save the connection info with the mail merge document. I use Automation to open the mail merge document and use Mailmerge.OpenDataSource to specify the SQL string and to connect to the database. After performing the mail merge, I close the source document without saving it.

      • #1165747

        The path to the Data doc is only: “C:AccessInsurancMergeDocsAppointment Letter Data.doc”, and has been operating unchanged for many years.

        I don’t use ‘Mailmerge.OpenDataSource to specify the SQL string and to connect to the database’. My way is a hangover of very early versions of Access, where to use an Access object as data source, started up another instance of Access. In those days, the less apps running the better. As it always worked very smoothly, I never changed it. It does have the advantage of enabling me to open the data doc to see who was the last recipient of that letter.

        • #1165749

          Does the problem occur on other PCs too, or only on yours?

          • #1165797

            Does the problem occur on other PCs too, or only on yours?

            Mmmm, interesting, I generally only write letters on my main computer, so I hadn’t tried the other computers. All 3 have the same problem. All have Office 2003; 2 have Vista and 1 has XP.

            • #1165841

              Have you tried other mail merges?

              I performed several mail merges today with text files as data source using Word 2003 SP3 (with all updates) on Windows XP Pro SP3 (with all updates); the merge document stored the connection info without problems.

            • #1166016

              I have gone through the code and can’t see why the problem is occurring. Hopefully you will be able to pinpoint the boo boo.
              Here is a stripped down version of the code.

              [codebox]Function PrintContactLetter(LetterF As Form)
              ‘Called from [Envelope Dialog] Form
              Dim S As String, Tb As String, St As String, MrgDir As String
              Dim ThisString As String, ThisDoc As String
              Dim Lf As String
              On Error GoTo Err_PrintContactLetter
              MrgDir = DLookup(“[MergeDirectory]”, “Paths”)
              Tb = Chr$(9): Lf = Chr$(10)
              S = “FirstName” & Tb & “LastName” & Tb & “Company” & Tb & “Street” & Tb & “Suburb”
              S = S & Tb & “Both” & Tb & “RepPd”
              On Error Resume Next
              Set appWd = GetObject(, “Word.Application”)
              On Error GoTo Err_PrintContactLetter
              If appWd Is Nothing Then
              Set appWd = CreateObject(“Word.Application”)
              End If
              If appWd Is Nothing Then
              MsgBox “Can’t start Word.”, vbExclamation
              GoTo Exit_PrintContactLetter
              End If
              ThisDoc = “ClientLetter.doc”
              On Error Resume Next
              ‘If the letter is open, we need to close it, so we can edit it’s data source doc.
              Name MrgDir & ThisDoc As MrgDir & ThisDoc
              If Err.Number 0 Then
              On Error GoTo Err_PrintContactLetter
              appWd.Documents(ThisDoc).Close SaveChanges:=wdDoNotSaveChanges
              End If
              On Error GoTo Err_PrintContactLetter
              appWd.Application.Visible = False ‘otherwise Word becomes visible here
              With appWd
              On Error Resume Next
              .Documents.Open MrgDir & “Appointment Letter Data.doc”
              If Err.Number 0 Then
              On Error GoTo Err_PrintContactLetter
              MsgBox “Can’t get names etc into the required doc.” & vbCrLf & _
              “You will have to close all ‘Insurance’ Word docs,” & vbCrLf & _
              “and try again!”, vbCritical
              GoTo Err_PrintContactLetter
              End If
              On Error GoTo Err_PrintContactLetter
              With .Selection
              .HomeKey Unit:=wdStory ‘Go to start of document
              .EndKey Unit:=wdStory, Extend:=wdExtend ‘Select whole document
              .Delete Unit:=wdCharacter, Count:=1 ‘Delecte the lot
              .InsertAfter S + Lf ‘insert field headings
              End With
              End With
              With LetterF
              St = ![Street]
              ThisString = Nz(![FirstName])
              S = ThisString & IIf(ThisString “”, ” “, “”) & Tb
              S = S & Nz(![LastName]) & Tb
              ‘function StripLineFeeds gets rid of any line feeds
              ‘within the fields causes Word to make a new record.
              S = S & StripLineFeeds(Nz(!Company)) & Tb
              S = S & StripLineFeeds(St) & Tb
              S = S & StripLineFeeds(Nz(![Suburb])) & Tb
              S = S & IIf(Nz(LetterF![SpouseToAddressCheckBox]), “yes”, “no”) & Tb
              S = S & Nz(![ReplyPd])
              End With
              With appWd
              .Selection.InsertAfter S
              .ActiveDocument.SaveAs MrgDir & “Appointment Letter Data.doc” ‘|Save now so no
              .Documents.Close wdDoNotSaveChanges ‘|dialog box on closing
              .Documents.Open MrgDir & ThisDoc
              .Visible = True
              .ActiveDocument.PageSetup.FirstPageTray = gMPBin ‘MP Tray
              .ActiveDocument.PageSetup.OtherPagesTray = wdPrinterLowerBin ‘Tray 2
              ”’ .WindowState = wdWindowStateMaximize ‘Taken out 17 Feb 09
              .Application.Activate
              End With
              DoCmd.Close acForm, LetterF.Name, acSaveNo
              Exit_PrintContactLetter:
              On Error Resume Next
              Set appWd = Nothing
              Exit Function

              Err_PrintContactLetter:
              MsgBox Err.Description
              Resume Exit_PrintContactLetter
              Resume
              End Function[/codebox]

    • #1165948

      Does this problem occur only when you replace the data document? In other words, if you try the merge again without replacing the data .doc file, does Word protest that it can’t find the document? Just wondering whether there is more to keeping the same data source than merely the file path and name.

    • #1166011

      I don’t have a solution but was wondering if the data connection is considered ‘personal information’ and might be removed when you choose to remove personal information from the document. I can’t recall whether Word 2003 even had this setting to remove personal information but Word 2007 certainly does.

    Viewing 2 reply threads
    Reply To: Word wont save mailmerge data connection

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: