• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Delete a person in AddressBook
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Delete a person in AddressBook


  • Subject: Delete a person in AddressBook
  • From: Robert R.Horning <email@hidden>
  • Date: Wed, 12 Nov 2008 08:31:47 -0700

I should have provided more information:

I have two Excel workbooks: one contains a list of peoples' names and their id's that are already in the addressbook,
the other contains a list of peoples' names and their contact information taken from a database. (The peoples
names consist of concatenated first, middle, and last names.) In a 'repeat loop' Excel goes down the second list
and, if the person appears in the first list (and therefore is already in the addressbook), feeds the id's and contact
information to Address Book to update its information. If Excel does not find the person in the first workbook,
the script instructs Address Book to make a new person; then Excel feeds the person's first, middle, and last names
and contact information to Address Book to fill in the blanks for that new person.


All this usually works, but occasionally Applescript throws the NSReceiverEvaluationScriptError while Address Book
is filling the blanks for the new person. This error causes the error handler to execute, attempting to delete the new
person so that the script can try again to add that person. (Btw, if the error handler does not attempt to delete the
person just entered, but simply dismisses the error and moves on to the next entry in the second workbook, the script
does not crash. Of course the information for the person just created is then incomplete.)


The error that comes back from the error handler after attempting to delete the person is:

Address Book got an error: Can't make person (person id "...") into type reference.

I've also tried copying ThePerson to another variable (tmpPerson) immediately after making new person and substituting tmpPerson for ThePerson in the delete statement. AppleScript throws the same error. And saving the addressbook before attempting the delete makes no difference.

Thanks for your help, Bob.
---
On Nov 6, 2008, Michelle wrote:

This works for me:

tell application "Address Book"
	set testPerson to make new person with properties {first name:"test",
last name:"test"}
	save addressbook
	tell testPerson
		try
			set its namenick to "foo"
		on error
			delete testPerson
			save addressbook
		end try
	end tell
end tell

There is no property "namenick", so the try fails, and falls into the
on error handler.

-- Michelle

---
On Nov 6, 2008, Robert R. Horning wrote:

I have the following snippet of script:

try
tell application "Address Book" to set ThePerson to make new person
...
(code to add information, such as the person's address.)
...
on error
...
end try

Every now and then back comes the following error:

NSReceiverEvaluationScriptError: 4
number 1

In the error handler, I wish to tell Address Book to delete ThePerson
so that I can start over, but have found no syntax that works.  Any
ideas?

Thanks, Bob.
PowerPC G5
OSX 10.4.11
(Plan to migrate to Intel and 10.5)


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Re: Are You Sure ?
  • Next by Date: Re: Are You Sure ?
  • Previous by thread: Delete a person in AddressBook
  • Next by thread: Open using
  • Index(es):
    • Date
    • Thread