Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    637
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mail Merge to Word errors (2003 SP2)

    Recently upgraded to Off2003. Went quite smoothly. But due to a number of problems I did a clean install of windows XP & Off2003. Now I get this error in mail merge (to Word) code that has run without fuss for years.
    Error message =
    Regards,
    Peter

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    You *must* specify the data source for the mail merge before you can set ViewMailMergeFieldCodes or Destination. If you try to set either before the data source has been specified, you'll get the error you mention.

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    637
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    Hans.
    In all the Dbs, specifying the data source is done in preceding code. This has been working wonderfully for years, but now, after the clean install, it has suddenly stopped. Very frustrating as I use this on a daily basis.
    Regards,
    Peter

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    Strange. I just now tested in Access 2003/Word 2003, and code similar to yours ran without errors, as long as the Destination was set after specifying the data source...

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    637
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    Yep, strange is right. I haven
    Regards,
    Peter

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    Sandbox mode restricts the use of VBA functions in expressions (i.e. in queries and in the control source of controls on forms/reports), but not the use of VBA in modules.
    The error message does not point to security problems; it indicates that the MailMerge object hasn't been initialized properly.

    If you wish, you can post more of the code you are using (in an attachment if it is long), or a stripped down version of the database.

  7. #7
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    637
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    Hans, I just re-read your email.
    Do you mean that in Office 2003 the data source must be specified every time? The Merge doc is a saved doc that has been saved attached to its data source. All I do in code is put the data in the word doc that serves as the data source. This has alway worked in the past.
    I have just added the line
    appWD.ActiveDocument.MailMerge.DataSource = MrgDir & DataDocName.
    But it gets the error
    Regards,
    Peter

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    If the main merge document has been saved with the data source already set, you don't need to set it anew. The data source information is stored with the document. (However, I prefer to store the document without the data source information and set it when it is needed.)

    The DataSource property is read-only. To set it, use the OpenDataSource method:

    appWD.ActiveDocument.MailMerge.OpenDataSource Name:=MrgDir & DataDocName

  9. #9
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    637
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mail Merge to Word errors (2003 SP2)

    Hans, thanks again!
    I was fiddling around and found the solution you suggest. e.g. .MailMerge.OpenDataSource MrgDir & DataDocName. The merge now works. But I can't see why is this now needed.
    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
  •