Office Address Book

R

Robert Barrimond

Recently tried to do a Data Merge for labels. Office Address Book only
includes the default address. Wrote a script to batch change work and home
addresses as default. It no longer works by changing the "default postal
address" property in each contact. Could use some help with this. Changing
dozens of contacts by hand is not my idea of fun...
 
P

Paul Berkowitz

Recently tried to do a Data Merge for labels. Office Address Book only
includes the default address. Wrote a script to batch change work and home
addresses as default. It no longer works by changing the "default postal
address" property in each contact.

Sure it does. You must be doing something wrong.
Could use some help with this.

We can't help if you don't include your script...
Changing
dozens of contacts by hand is not my idea of fun...


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
P

Paul Berkowitz

(I meant to send it pasted in, but the attachment arrived unscathed.)

You have included a common or garden script error:


if "default postal address" is equal to editContactProperty then
set editContactPropertyValue to (choose from list
{"home", "work"} with prompt "Select default address:" without multiple
selections allowed)


You forgot to add 'as string', or to get item 1 of the result. So the
result, if you choose "home", is

--> {"home"}

not "home". Therefore, a few lines lower:

else if editContactProperty is equal to "default postal
address" then
if editContactPropertyValue is equal to "home" then
set default postal address of (item i in
contactList) to home
else
set default postal address of (item i in
contactList) to work
end if -- editContactPropertyValue = home



Since editContactPropertyValue is not equal to "home" (it's {"home"}), the
'else' tells it to

set default postal address of item i in contactList to work

so that's precisely what it does. If you fix the error in the first line
quoted to


set editContactPropertyValue to (choose from list {"home",
"work"} with prompt "Select default address:" without multiple selections
allowed) as string


then the rest of it works as you'd like.



By the way, if you ever run the script without selecting a contact you won't
get the display dialog you expect, since there's another error there:

if length of contactList is less than 1 then -- only run if user actually
selected some contacts
display dialog "Please select one or more contacts before
running script." without cancel


There's no such parameter as 'without cancel' (there's no boolean 'cancel'
parameter in 'display dialog'). You can see that from the formatting:
'cancel' is colored as a variable, not a keyword. You'd get an Error: "The
variable cancel is not defined." I think you mean this:

display dialog "Please select one or more contacts before running
script." buttons {"OK"} default button 1 with icon 0





--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
R

Robert Barrimond

(I meant to send it pasted in, but the attachment arrived unscathed.)

You have included a common or garden script error:


if "default postal address" is equal to editContactProperty then
set editContactPropertyValue to (choose from list {"home",
"work"} with prompt "Select default address:" without multiple selections
allowed)


You forgot to add 'as string', or to get item 1 of the result. So the result,
if you choose "home", is

--> {"home"}

not "home". Therefore, a few lines lower:

else if editContactProperty is equal to "default postal
address" then
if editContactPropertyValue is equal to "home" then
set default postal address of (item i in
contactList) to home
else
set default postal address of (item i in
contactList) to work
end if -- editContactPropertyValue = home



Since editContactPropertyValue is not equal to "home" (it's {"home"}), the
'else' tells it to

set default postal address of item i in contactList to work

so that's precisely what it does. If you fix the error in the first line
quoted to


set editContactPropertyValue to (choose from list {"home",
"work"} with prompt "Select default address:" without multiple selections
allowed) as string


then the rest of it works as you'd like.



By the way, if you ever run the script without selecting a contact you won't
get the display dialog you expect, since there's another error there:

if length of contactList is less than 1 then -- only run if user actually
selected some contacts
display dialog "Please select one or more contacts before running
script." without cancel


There's no such parameter as 'without cancel' (there's no boolean 'cancel'
parameter in 'display dialog'). You can see that from the formatting: 'cancel'
is colored as a variable, not a keyword. You'd get an Error: "The variable
cancel is not defined." I think you mean this:

display dialog "Please select one or more contacts before running
script." buttons {"OK"} default button 1 with icon 0
Thanks Paul!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top