Results 1 to 12 of 12
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Regards,
    Peter

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The path to the Data doc is only: "C:\Access\Insuranc\MergeDocs\Appointment 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.
    Regards,
    Peter

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Does the problem occur on other PCs too, or only on yours?

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='780952' date='22-Jun-2009 17:57']Does the problem occur on other PCs too, or only on yours?[/quote]
    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.
    Regards,
    Peter

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    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.

  8. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    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.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #9
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans: Other docs are doing the same.

    jscher: Interesting thought. If I simply re-open the mail merge letter - the data is still attached. If I manually alter the data doc (not through Access), the mail merge doc is still attached to the data source and reflects the changes. So it looks like you have isolated Access as the cause.

    Andrew: I haven't set the docs to remove personal info.

    Thanks guys, I will step through the code to see if I can find the bug. Any ideas would still very much be appreciated.
    Regards,
    Peter

  10. #10
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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]
    Regards,
    Peter

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Do you have Access 2003 SP3? If so, you might try the two post-SP3 hotfixes released by Microsoft:
    Access 2003 post-Service Pack 3 hotfix package: November 21, 2007
    Access 2003 post-Service Pack 3 hotfix package: December 18, 2007
    They don't list the problem that you have, but they correct several bugs in SP3.

  12. #12
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='781132' date='23-Jun-2009 10:01']Do you have Access 2003 SP3? If so, you might try the two post-SP3 hotfixes released by Microsoft:
    Access 2003 post-Service Pack 3 hotfix package: November 21, 2007
    Access 2003 post-Service Pack 3 hotfix package: December 18, 2007
    They don't list the problem that you have, but they correct several bugs in SP3.[/quote]

    thanks for that Hans, but I didn't need to. I just added the line:
    appwd.ActiveDocument.MailMerge.OpenDataSource DataDoc
    to the code. Works like a charm.
    Thanks guys.
    Regards,
    Peter

Posting Permissions

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