Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Mailmerge Insert Blank Line (VBA-Word 2003)

    Hi,

    Im trying to amend a mail merge script to insert a blank line in the address of a label. The relevant code is below and I have assumed that the 'chr(13)' relates to a carriage return, however after an hour or so of testing this no longer seems to be the case;

    With docMerge.MailMerge
    .MainDocumentType = wdMailingLabels
    .OpenDataSource _
    Name:="C:TestSLabels.csv", ConfirmConversions:=False, ReadOnly:= _
    False, LinkToSource:=True, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:="", WritePasswordDocument:="", WritePasswordTemplate:= _
    "", Revert:=False, Format:=wdOpenFormatAuto, Connection:="", SQLStatement _
    :="", SQLStatement1:="", SubType:=wdMergeSubTypeOther
    ActiveDocument.Fields.Add Range:=Selection.Range, Type:= _
    wdFieldAddressBlock, Text:= _
    "f ""<< _TITLE0_>><< _FIRST0_>><< _LAST0_>><<" & Chr(13) & ">><<_STREET1_>>"" l 2057 c 2 e ""U"
    WordBasic.MailMergePropagateLabel
    docMerge.Activate
    With .DataSource
    .FirstRecord = wddefaultspace
    .LastRecord = wdDefaultLastRecord
    End With


    I suspect something needs to be inserted just after 'wdFieldAddressBlock, Text', but Im at a loss as to what and where. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>

    Any help would be grately appreciated.

    Cheers.
    Lee

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

    Re: Mailmerge Insert Blank Line (VBA-Word 2003)

    I always avoid the AddressBlock field, and insert the individual fields where I need them. If you prefer to keep the Addressblock, try removing the << before and >> after the Chr(13). And I don't know what the U near the end does - I'd remove it too.
    <code>
    ..., Text:= _
    "f ""<<_TITLE0_>><<_FIRST0_>><<_LAST0_>>" & Chr(13) & "<<_STREET1_>>"" l 2057 c 2"
    </code>
    Note: as you can see in your code by the lack of capitalisation, wddefaultspace is not valid. Use wdDefaultFirstRecord instead, or omit this part altogether - by default, all records will be merged.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Mailmerge Insert Blank Line (VBA-Word 2003)

    Hi Hans,

    I removed the << & >> before and after the Chr(13) and it now works a treat, putting in the spaces where necessary.

    Thanks for your help, its much appreciated.

    Cheers. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Lee

Posting Permissions

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