Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Mail merge letter, then change header (2000 SR1A)

    We've created a letterhead template for one department in our law firm that's merged with a database, where the letter is automatically generated via VBA code after the data is selected. However, some attorneys in the firm want to use a different letterhead , one with all the attorneys' names listed, instead of the "generic" letterhead we set up that contains NO attorneys' names. (The problem with using the attorney-name letterhead is, attorneys come and go so we're constantly updating the template for that letterhead, which isn't practical for purposes of the department that uses this particular database and template.) So I'm wondering if anyone knows of a way we could take our basic letterhead, generate the letter from the database, and then, perhaps with one keystroke or one click on a toolbar icon, dynamically generate a new header in place of the existing header. Got any ideas??
    Cyndie Browning
    GableGotwals
    Tulsa, OK

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

    Re: Mail merge letter, then change header (2000 SR1A)

    Would the header with all the attorneys be generated dynamically from a database too, or could it be static text? If the latter, you could make it into an AutoText entry; it would be relatively simple to create a macro that inserted this AutoText entry into the header.

  3. #3
    New Lounger
    Join Date
    Jan 2003
    Location
    Tulsa, Oklahoma, USA
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Mail merge letter, then change header (2000 SR1A)

    Yes, thanks.... I already thought of that and, indeed, AutoTexting the header does work. However, the powers-that-be were hoping to find one all-inclusive "magic trick" they could perform (or rather, that _I_ could perform) that would remove the existing header and replace it with the AutoTexted header, all in one fell swoop. I even wrote a macro to do it but in the macro, the hard text formatting in the inserted header didn't "stick"; that is, if you simply activate the AutoTexted text, it drops in fine, but running in the macro, the text is dropped in without its direct font formatting, which means it's as good as no header at all. Thanks for the suggestion, tho'; I do appreciate it.
    Cyndie Browning
    GableGotwals
    Tulsa, OK

  4. #4
    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: Mail merge letter, then change header (2000 SR

    When you insert AutoText there is a parameter that controls whether the formatting is preserved. This is some code I use to insert an AutoText entry into the First Page header of Section 1 of a document:
    <pre>Sub InsertIntoFirstPageHeader(docTarget As Document, strATName As String, _
    Optional blnPreserve As Boolean = False)
    ' Created 10/04/03 Jefferson Scher

    ' Set up object references
    Dim atSource As Template, intCounter As Integer, rngInsertHere As Range
    For intCounter = 1 To Templates.Count
    If Templates(intCounter).Name = MacroContainer.Name Then
    Set atSource = Templates(intCounter) ' Object ref to this template
    Exit For
    End If
    Next

    ' Set destination range to header; collapse if header is not to be replaced
    Set rngInsertHere = docTarget.Sections(1).Headers(wdHeaderFooterFirstP age).Range
    If blnPreserve Then
    rngInsertHere.Collapse wdCollapseStart
    End If

    ' Insert the letterhead autotext entry
    atSource.AutoTextEntries(strATName).Insert _
    Where:=rngInsertHere, _
    <span style="background-color: #FFFF00; color: #000000; font-weight: bold">RichText:=True</span hi>

    ' Remove trailing paragraph mark from the header if prior header was not preserved
    If Not blnPreserve Then
    docTarget.Sections(1).Headers(wdHeaderFooterFirstP age).Range.Characters _
    (docTarget.Sections(1).Headers(wdHeaderFooterFirst Page).Range.Characters.Count) _
    .Delete
    End If

    ' Clean up objects
    If Not (atSource Is Nothing) Then Set atSource = Nothing
    If Not (docTarget Is Nothing) Then Set docTarget = Nothing
    If Not (rngInsertHere Is Nothing) Then Set rngInsertHere = Nothing
    End Sub</pre>

    This has been running in the Firm for many months and as far as I know, it is reliable. However, no warranties. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Mail merge letter, then change header (2000 SR1A)

    If the letterhead consitst of a basic part, that's the same for all departments, and an often changing list of attorneys, maybe it's a good idea to use a standard INI file to store the names of the attorneys. Then you could write a little macro to read these names and put them in the header each time a doc is created. The advantages are, that the INI file can have a section with a list of names for every department, it can be used in different templates, and it is easy to edit when attorneys come and go.
    If you like this approach and need help creating the macro, let me know.

Posting Permissions

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