'=============================================================
' Dial Macro for Word for Windows using METZ Phones
' Noel Sterrett, 1991
'=============================================================
' This macro uses METZ Phones to dial a telephone number which is
' highlighted in Word.  If a DDE timeout occurs, add "DDETMEOUT=n"
' to WIN.INI under the heading "[Microsoft Word]".
' Adjust n (seconds) for your needs.
Sub MAIN
dial$=PrepairDial$(Selection$())
Print dial$

DDETerminateAll
chan=DDEInitiate("PHONES", "DIAL")
DDEExecute chan, dial$
DDETerminate chan

End Sub

'-----------
Function PrepairDial$(numb$)
'the following codes should be modified to suit your telephone system:
local$="99,"
long$="99,1,"
mci$="99,1,"
bill$=",,,,,,31"

tele$=""
junk$="()-,."
For i=1 To Len(numb$)
    ch$=Mid$(numb$, i, 1)
    If InStr(junk$, ch$) = 0 Then tele$=tele$+ch$
Next i

code=Int(Val(tele$) / 10000000)
If Val(tele$) < 10000 Then    'inside call
   PrepairDial$=tele$
ElseIf code=0 Then            'local call
   PrepairDial$=local$+tele$
ElseIf code=800 Then          'free call
   PrepairDial$=long$+tele$
Else                          'long distance pay call
   PrepairDial$=long$+tele$
End If

End Function
