Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Extract Address Code - Done! (97 SR2)

    Found some interesting things about programming this
    dialog. Too boring to relate the details here. The code will
    grab an address that has new line or paragraph mark line
    breaks. Word's will only grab addresses w/ para marks. Also,
    if the address is part of a memo TO: line, the TO: is not
    grabbed. Not the hottest item on the market right now, but at
    least it's success! (Unless you find a bug. Let me know.)

    <pre>Sub ToolsEnvelopesAndLabels()
    Dim dlg As Dialog
    Dim strAddress As String

    Set dlg = Dialogs(wdDialogToolsEnvelopesAndLabels)
    With dlg
    .DefaultTab = wdDialogToolsEnvelopesAndLabelsTabEnvelopes
    .EnvOmitReturn = True
    .EnvPaperName = "Automatically Select"

    'Move to first zip code
    Selection.Collapse wdCollapseStart
    With Selection.Find
    .ClearFormatting
    .Text = "[0-9]{5}[^13^11^45]"
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Forward = True
    .Execute
    If .Found Then
    With Selection
    .MoveEnd Unit:=wdLine
    .Collapse wdCollapseEnd
    .Extend
    With .Find 'Select address in memoradumn
    .ClearFormatting
    .Text = ":^t"
    .Forward = False
    .Wrap = wdFindStop
    .Execute
    End With
    End With
    If .Found Then
    Selection.MoveRight Unit:=wdCharacter, Count:=2
    strAddress = RemoveTrailingCR(Selection.Range.Text)
    Selection.Collapse wdCollapseEnd
    Else
    'if not found, then let Word do the pickup
    dlg.ExtractAddress = True
    End If
    Else
    'No address found
    MsgBox "No address found. Click on an address to
    print an envelope. Try again.", _
    vbInformation, "Error: Print Envelope"
    Exit Sub
    End If
    End With
    .AddrText = strAddress
    .Show
    End With

    Set dlg = Nothing
    End Sub
    </pre>

    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Extract Address Code - Done! (97 SR2)

    Don't trust that code. Egg on face. Debugging now...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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