Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word97, MailMerge and SendTo (W97, SR-2)

    I'm having difficutly in writing code that will mail merge a document with it's attached file. The attached file contains a field for the email address and one merge field with text that is passed to the document. The code
    listed below tries to merge the first record, email that document, close the active document and loop through the process until the last record has
    been processed. As you can see from the lines of code that have been rem'd out, I'm having a fun time at this.

    Any advice would truly be appreciated.

    John


    The code is as follows:

    Sub test()
    Counter = 0
    With Documents("HLBFS.Doc").MailMerge
    ' .Destination = wdSendToNewDocument
    .Destination = wdSendToEmail
    .MailAsAttachment = False
    .MailAddressFieldName = "Email"
    .MailSubject = "2002 Budget"
    .SuppressBlankLines = True
    .DataSource.ActiveRecord = LastPosition
    .DataSource.ActiveRecord

    Do Until Counter <= LastPosition
    Counter = Counter + 1
    With .DataSource
    .FirstRecord = Counter
    .LastRecord = LastPosition
    End With
    .Execute

    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

    Loop
    End With
    End Sub

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word97, MailMerge and SendTo (W97, SR-2)

    Hi John, this looks like a case for putting in some comments so we can figure out what you are trying to do. I tried to compile this and encountered some problems:

    The line
    .DataSource.ActiveRecord
    is not legal.

    Prior to that, you are setting the ActiveRecord to a value that you haven't set yet, at least not in this subprocedure.

    Later on, you have a loop where the condition is based on this value that hasn't been set yet:
    Do Until Counter <= LastPosition

    Can you make it work interactively? I use Word 2000 now, and when I do a merge to e-mail interactively, I don't need to close the document in between messages. I think this could inadvertently close the master merge document.

    Well, hope this gives you some ideas.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word97, MailMerge and SendTo (W97, SR-2)

    Thanks for your suggestions. As you can tell by some of the code, I've gone in a complete circle. I'm very familiar with XL macros and based on my experience with it the macros in W97 should not be that much different; nor this task at hand. Unfortunately I've confused myself and need some assistance with the code or writing new code. Any assistance You or any other Lounger may have would be truly appreciated.

Posting Permissions

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