Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Dec 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA Mail Merge conversion to 2003 (2003)

    I am initiating a mail merge in Word via Access which works great in Access 2002:

    'Create a Word instance
    Set appWord = CreateObject("Word.Application")
    appWord.Visible = True

    'Open the selected merge document
    strWordDoc = Me!Path & Me!LetterName.Column(1)
    appWord.Documents.Open strWordDoc

    With appWord
    '.ActiveDocument.MailMerge.OpenDataSource Name:=strFile, _
    ' SubType:=wdMergeSubTypeWord2000, Format:=wdOpenFormatText
    .ActiveDocument.MailMerge.Destination = wdSendToNewDocument
    .ActiveDocument.MailMerge.Execute
    .Documents(strWordDoc).Close SaveChanges:=wdDoNotSaveChanges
    End With


    BUT...generates the following error in Access 2003: Requested object is not available

    Something changed in 2003, but I'm not sure what. Does anyone know?

    Thanks!

    Larry

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

    Re: VBA Mail Merge conversion to 2003 (2003)

    Which line causes the error?

  3. #3
    Lounger
    Join Date
    Dec 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Mail Merge conversion to 2003 (2003)

    The error is caused by the line

    .ActiveDocument.MailMerge.Destination = wdSendToNewDocument

    Because wdSendToNewDocument is empty

    Is this a change with Access 2003?

    Thanks!

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

    Re: VBA Mail Merge conversion to 2003 (2003)

    Have you set a reference to the Microsoft Word 11.0 Object Library in Tools | References...?

  5. #5
    Lounger
    Join Date
    Dec 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA Mail Merge conversion to 2003 (2003)

    Duhhh - didn't check when I changed versions. Thanks.

    Now I get the same error on the same line, but the value of wdSendToNewDocument=0 instead of empty.

    Larry

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

    Re: VBA Mail Merge conversion to 2003 (2003)

    You can't set the destination before initializing the mail merge, either by specifying the MainDocumentType:

    .ActiveDocument.MailMerge.MainDocumentType = wdFormLetters

    or by opening the data source - this part is commented out in your code:

    .ActiveDocument.MailMerge.OpenDataSource ...

Posting Permissions

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