Title: Re: Address Formatting Preference - inoperable?
The field is set so that the automatic formatting happens ONLY the first time you type something into the field and tab out of it. Once you have anything in there, even a blank space, it won't autoformat. There is a good reason for this: not everyone lives in the USA with our format of telephone numbers. It is necessary to allow users to format it manually as they desire, in order to accommodate non-US telephone formats. The one-time-only formatting was implemented in an attempt to provide the best of both worlds to us USA customers, who are the largest single group of Entourage users.
I wrote a script that will reformat telephone numbers. It takes a 7 or 10 digit number, in any format, and strips out everything but digits, and then reformats it as "(nnn) nnn-nnnn" or "nnn-nnn-nnnn". You have to edit the script and change the appropriate lines below to pick the second format:
-- Insert USA telephone formatting
--Choose one of two formats, comment out one unused
set mask to "(AAA) PPP-NNNN"
-- set mask to "AAA-PPP-NNNN"
You can test the script by selecting a telephone number, unformatted, in any text area, and then running the script in Entourage. It will reformat the phone number on the clipboard and paste it in place of the selected number. Since it is also on the clipboard, you can then paste wherever you like.
To reformat phone numbers for contacts, just select one or more contacts in the Address book and run the script. It will reformat the home and work phone numbers (just the main ones).
Copy the script below into script editor, save it in your Entourage Script Menu Items folder, and then run it from the Script menu in Entourage.
tell application "Microsoft Entourage"
activate
try
set theList to the selection
on error theErr number errNum
if errNum = -1728 then
-- Try formatting the text on the clipboard
set t to the clipboard
set t to my reformat(t)
set the clipboard to t
try
set the selection to t
on error
display dialog "Clipboard now contains: " & t
end try
return
else
display dialog "Error number:" & errNum & " " & theErr
return
end if
end try
repeat with theC in theList
if class of theC is not contact then
if (class of theC is string) or (class of theC is Unicode text) then
-- Try formatting the text on the clipboard
set t to the clipboard
set t to t as text
set t to my reformat(t)
set the clipboard to t
try
set the selection to t
on error
display dialog "Clipboard now contains: " & t
end try
return
end if
display dialog "No contacts are selected."
return
end if
-- set theC to contact "Jenna Burrell"
tell theC
set home phone number to my reformat(home phone number)
set business phone number to my reformat(business phone number)
end tell
end repeat
end tell
on onlyDigits(s)
-- Strip all but digits from a string
set theDigits to "1234567890"
set newS to ""
repeat with i from 1 to length of s
set c to character i of s
if c is in theDigits then set newS to newS & c
end repeat
return newS
end onlyDigits
on formatNum(n)
-- Insert USA telephone formatting
--Choose one of two formats, comment out one unused
set mask to "(AAA) PPP-NNNN"
-- set mask to "AAA-PPP-NNNN"
if length of n is 10 then
set aaa to text 1 thru 3 of n
set ppp to text 4 thru 6 of n
set nnnn to text 7 thru 10 of n
set mask to my searchReplace(mask, "AAA", aaa)
set mask to my searchReplace(mask, "PPP", ppp)
set mask to my searchReplace(mask, "NNNN", nnnn)
set n to mask
else if length of n is 7 then
set n to text 1 thru 3 of n & "-" & text 4 thru 7 of n
end if
return n
end formatNum
on reformat(pNum)
set pNum to my onlyDigits(pNum)
set pNum to my formatNum(pNum)
return pNum
end reformat
-- routine to do a search and replace on text
on searchReplace(mainString, searchString, replaceString) -- Parameters: search, replace, the String
set olddelis to AppleScript's text item delimiters
set AppleScript's text item delimiters to (searchString)
set theList to (every text item of mainString)
set AppleScript's text item delimiters to (replaceString)
set theString to theList as string
set AppleScript's text item delimiters to olddelis
return theString
end searchReplace
On or near 1/9/03 9:35 AM, Mark Christiansen at [EMAIL PROTECTED] observed:
> Just FYI, rebuilding the database did help fix this problem with new entries
> - they now work - but the old entries aren't changed, even if I go back into
> the given field and tab to enter the number. If I edit it in any way, it
> gets deleted too.
>
> So thanks, Mickey, for solving this for new numbers.
>
> On 1/8/03 9:28 PM, Gary Lists wrote:
>
>> On or about 1/8/03 9:33 PM, Mark Christiansen wrote:
>>
>>> Am I misinterpreting this feature, or is it broken?
>>
>> It is broken. It has never worked properly in Entourage for me either
>> (since the first release of E2001). What I enter is what I get. No amount of
>> cajoling the preferences seems to affect the outcome of the format.
>> --
>> Gary
>>
>>
>
--
Microsoft MVP for Entourage/OE/Word (MVPs are volunteers)
Allen Watson <[EMAIL PROTECTED]> Entourage FAQ site: <http://www.entourage.mvps.org/>
AppleScripts for Outlook Express and Entourage:
<http:[EMAIL PROTECTED]/Scripts/>
Entourage Help Pages: <http://www.entourage.mvps.org/>
- Address Formatting Preference - inoperable? Mark Christiansen
- Re: Address Formatting Preference - inoperable? Mickey Stevens
- Re: Address Formatting Preference - inoperable? Gary Lists
- Re: Address Formatting Preference - inoperable? Mark Christiansen
- Allen Watson
