Applescript for address book

Is there a way to click on a contact name, have apple script capture first name, last name, address, then print these in a document? I know I can use mail merge in Pages, but can't in other text editors

OK, sorry. So I dictate medical reports in Macspeech Dictate. I do a bunch at a time. I have to dictate a report to Dr. Jones, so I want to insert using address book:
Joe Jones, M.D.
1234 1st St.
Kansas City, KS 66111
then I dictate the letter to Dr. Jones, then I dictate the next letter to Dr. Smith, etc.
at the end of the day's dictation I have a single document that has ~20 medical reports. I have a macro that I've used for 8 yrs in MS Word to split the letters up, save them in individual files, print them properly formatted on letterhead. I recently have switched to Pages & have developed an applescript to do the same thing. I could dictate, save, print letters one at a time, then I could use the script the way you originally wrote it, but my workflow is more efficient to do it all at once. I guess I'm stuck in my ways, but, again, I think it works better to finish the dictation for the whole day and let my macro save, format, and print all the reports at once. So that's why I want to put the addresses in an already made document.
So here's the code I'm using:
(I added in 2 lines of code to save the selected addresses in a group "envelope" so I can drag & drop them into a Pages mail-merge document to print out the envelopes for the day's dictation)
tell application "Address Book"
--the next 2 lines are to store selected addresses in group envelope that I can drag and drop into a pages merge document to print out all the envelopes for the day's dictation
add the selection to the group "envelope"
save addressbook
set theContacts to the selection
repeat with thisPerson in theContacts
set theName to name of thisPerson
set theStreet to street of first address of thisPerson
set theCity to city of first address of thisPerson
set theState to state of first address of thisPerson
set theZip to zip of first address of thisPerson
end repeat
end tell
set CSZ to theCity & ", " & theState & " " & theZip
activate application "Macspeech Dictate Medical"
tell application "System Events"
keystroke theName
key code 36
keystroke theStreet
key code 36
keystroke CSZ
end tell
I ran this code on my macbook pro running 10.5.8 and my imac running 10.5.8. I made a brand new entry in the address book using a multiline street address and it doesn't put the line breaks. Otherwise, this macro works great. Weird, huh!
Thanks for your help & patience.

Similar Messages

  • AppleScript for address book stopped working in snow leopard

    I had an AppleScript stop working after upgrade to snow leopard. I select an address and it moves it to a group "envelopes" then prints the address in my current document. Later, I make a mail merge document of "envelopes and print out the envelopes for the day. Now it hangs up at the line:
    Add the selection to the group "envelopes"
    What is the new syntax to accomplish this? Not ready to abandon snail mail

    tell application "MacSpeech Dictate Medical"
      set bundleID to (bundle identifier of current context)
    end tell
    set _currentAppName to short name of (info for (path to application id bundleID as alias))
    --adds the selection to the group "envelope" to drag and drop later into a Pages mail merge to print out the day's envelopes
    tell application "Address Book"
      add the selection to the group "envelope"
      save addressbook
    --compile theaddress and print in current document of macspeech dictate medical
      set theContacts to the selection
      repeat with thisPerson in theContacts
      set theName to name of thisPerson
      set theStreetstring to street of first address of thisPerson
      set theStreet to paragraph 1 of theStreetstring
      try
      set theStreet2 to paragraph 2 of theStreetstring
      set theStreet to theStreet & return & theStreet2
      end try
      try
      set theStreet3 to paragraph 3 of the theStreetstring
      set theStreet to theStreet & return & theStreet3
      end try
      set theCity to city of first address of thisPerson
      set theState to state of first address of thisPerson
      set theZip to zip of first address of thisPerson
      end repeat
    end tell
    set theaddress to theName & return & theStreet & return & theCity & ", " & theState & " " & theZip
    tell application "System Events"
      keystroke theaddress
    end tell

  • Old computer I had is OSX Snow Leopard with Entourage. New one is OSX Mavericks. Using Mail where are my addresses and old address book. Transferred old computer backup by Time Machine and other things work? Can't see a symbol for address book.

    Old computer I had is OSX Snow Leopard with Entourage. New one is OSX Mavericks. Using Mail where are my addresses and old address book. Transferred old computer backup by Time Machine and other things work? Can;t see a symbol for address book.

    Where are addresses kept on MAIL?  I don;t like the new format at all. Frances
    Begin forwarded message:
    From: Frances Topping <[email protected]>
    Subject: Re: - Old computer I had is OSX Snow Leopard with Entourage. New one is OSX Mavericks. Using Mail where are my addresses and old address book. Transferred old computer backup by Time Machine and other things work? Can't see a symbol for address book.
    Date: August 25, 2014 at 9:46:01 AM EDT
    To: discussions-replies <[email protected]>
    Old Entourage is POP and new Mavericks MAIL  is IMAP I believe. I don;t know how to export in the forms you mention. Frances

  • Sync is currently unavailable for address book because of wireless sync

    I am trying to sync by calendar and address book.
    Works for the Calendar but not Address Book.
    I get the following Sycn Warning message. Synchronization unavailable for: Address Book because the application(s) is (are) configured for wireless synchronization. Desktop synchronization for the above application(s) will be disabled. click here for information how to disable wireless sync on your device.
    Followed instructions to the letter numerous times and it doesn't work.
    HELP!

    Are you connected to a BlackBerry Enterprise Server? If so you can delete one service book on your device, and this will allow you to sync your device through the wire.
    To do this go to: Option> Advanced Options> Service Book. In here look for the Desktop  [SYNC] service book. Press the menu key and choose delete.
    Now you should be able to sync your device with Outlook. Once the sync is done go back to: Option> Advanced Options> Service Book. Press the menu key and choose undelete.
    Hope this helps.

  • Tags or keywords for Address Book?

    I'm surprised to find that Address Book doesn't seem to offer any sort of tags, keywords, or categories for contacts. I've searched the web and can't seem to find any information about this, or a plugin that do for Address Book what MailTags does for Apple Mail. Does anyone know of something to help???

    I mostly use groups for both those purposes. I also use the company field as a sort of tag, since very few of my contacts are companies rather than individual. So I have contacts with builder or plumber or electrician in the company field - but this won't work for you if you need that field for company names. The other field you can use is the notes field; you could put several tags in, and you wouldn't need any special separator as search will find them.
    The advantage of groups, for me, is that you only have to type the tag or category once and you can so quickly isolate all those in the group. A contact can of course be in multiple groups; indeed a group can be in a group.
    AK

  • Can't find Application Support for Address Book in Lion. Any ideas where to go?

    I need to re-establish my Address Book after iCloud doubled all of the entries in it. But I can't find Application Support for Address Book in Lion.
    Can someone help?

    Go menu -> Go to folder.
    Enter ~/Library
    And select Go.
    Your contents will now be visible.  
    WARNING: messing around with these contents without at least twice backups may make your data inaccessible or worse if you don't know what you are doing.

  • Groupwise Field Definitions for Address Book entry

    Hi,
    I am looking for Groupwise Field definitions i.e. Field Names associated with Address Book entry (Contact and Organization). I am using OAPI to access the Contact's field values and set the Contact's field values by Field Name. Is there any place which has the list of all the field Names associated with Contact and Organization Address Book entry.
    Note: Field Definitions for Address Book entries that are in PAB.
    I also look for the comparision of Field Names in Groupwise 7.0 and Groupwise 8.0.
    Thanks,
    Pranav

    Why don't you iterate through all the field definitions of a given abook?
    This will give you the list of all possible fields for an entry.
    Markus
    "pranov2001" <[email protected]> schrieb im Newsbeitrag
    news:[email protected]..
    >
    > Hi,
    >
    > I am looking for Groupwise Field definitions i.e. Field Names
    > associated with Address Book entry (Contact and Organization). I am
    > using OAPI to access the Contact's field values and set the Contact's
    > field values by Field Name. Is there any place which has the list of all
    > the field Names associated with Contact and Organization Address Book
    > entry.
    > Note: Field Definitions for Address Book entries that are in PAB.
    >
    > I also look for the comparision of Field Names in Groupwise 7.0 and
    > Groupwise 8.0.
    >
    > Thanks,
    > Pranav
    >
    >
    > --
    > pranov2001
    > ------------------------------------------------------------------------
    > pranov2001's Profile: http://forums.novell.com/member.php?userid=82100
    > View this thread: http://forums.novell.com/showthread.php?t=406199
    >

  • Source code for address book

    hi everyone,
    i have to make a contact wizard for iphone, i have allready designed the view for contact wizard using navigation controller, there are 3 pages total which includes UITextFields, PickerView, and Table View.
    Now i dont know where to write code for add contacts in address book database.
    can any one help me by some code sample...?????
    i have written code in a function which is called on the Navigation toolbar Button
    the code is
    ABRecordRef aRecord = ABPersonCreate();
    CFErrorRef anError = NULL;
    ABRecordSetValue(aRecord, kABPersonFirstNameProperty,
    CFSTR("Jijo"), &anError);
    ABRecordSetValue(aRecord, kABPersonLastNameProperty,
    CFSTR("Pulikkottil"), &anError);
    if (anError != NULL) {
    NSLog(@"error while creating..");
    CFStringRef firstName, lastName;
    firstName = ABRecordCopyValue(aRecord, kABPersonFirstNameProperty);
    lastName = ABRecordCopyValue(aRecord, kABPersonLastNameProperty);
    ABAddressBookRef addressBook;
    CFErrorRef error = NULL;
    addressBook = ABAddressBookCreate();
    BOOL isAdded = ABAddressBookAddRecord (
    addressBook,
    aRecord,
    &error
    if(isAdded){
    NSLog(@"added..");
    if (error != NULL) {
    NSLog(@"ABAddressBookAddRecord %@", error);
    error = NULL;
    BOOL isSaved = ABAddressBookSave (
    addressBook,
    &error
    if(isSaved){
    NSLog(@"saved..");
    if (error != NULL) {
    NSLog(@"ABAddressBookSave %@", error);
    CFRelease(aRecord);
    CFRelease(firstName);
    CFRelease(lastName);
    CFRelease(addressBook);
    But it is showing many errors.
    can any one give me some advice how to manage it?

    You probably won't get much help here... this is a user forum, not a developer or programmer forum.

  • Database Manager for Address Book

    Help me! I seem to need to reconstruct my Address Book every time I change my PDA. the card formats are never quite the same....
    To date, I have been exporting to text files, cleaning the text tile with MS Word, opening the text file in Excel - doing my clean up and reorganization in Excel - saving as a text file, then importing the text file back into Address Book.
    Eh - and every time I do this, SOMEthing get screwed up. This time, I lost all the fax numbers!
    Question: Is there a database manager that will open the AddressBook.Data file in native format, allow me to make global changes or individual edits and resave the native format - without needing to do all of the exporting and importing and data corruption?
    Thanks for any feedback or comment!
    iMacG5 & PB 12"G4 & PB 15" Ti (G4)   Mac OS X (10.4.5)   Extreme Basestation & Belkin Enet Switch

    look at <http://homepage.mac.com/sroy/addressbookimporter>
    maybe this solves your problem.
    What PDA are you using?

  • Access via command line to the data files for Address Book

    Snow Leopard Server 10.6.8
    Mac Mini 2.66 GHZ Intel Core 2 Duo 4 GB 1067 MHZ DDR3
    I rolled back from Mountain Lion Server to Snow Leopard Server because I needed mySql. At the time I was under AppleCare and they walked me through the steps. However, I ended up with Address Book issues.
    Addressbook user on the Snow Leopard Server was upgraded to Mountain Lion Server. During the rollback process, the Apple tech had me delete the Addressbook user.
    When we finished the rollback, he had me recreate the Addressbook user, but now it is linked to a new, empty data file. I cannot add new contacts nor edit or delete them. So I need to use the command line to view both data store files, find the one that has my data in it and re-attach it to my new Addressbook user.
    Can someone help me with the Command Line commands?
    Thank you,
    Cailyn

    Hi,
    There are a couple of more advanced solution I can think of and I'm actually working on one myself.
    * You can create your own jnlp client that allows you to pass in arguments. That sounds harder than it easy. Building a stripped down jnlp client (e.g. no installer, no applets) using one of the two open-source client as a start takes probably just a couple of days and should be sufficient for in house usage.
    * Another solution is what I'm working on now. You can wrap your own executable around javaws that takes your passed in arguments plus jnlp href and looks up the original in the cache and adds a new one to the cache that it passes on to javaws and suddenly everything works as it should. The magic will be revealed at http://www.geocities.com/vamp201
    - Gerald Bauer

  • Need help setting up LDAP server for Address Book

    I've set up Panther servers before for AFP which is pretty simple but now the office I work at wants me to setup an LDAP server so they can share the same contact information, probably about 2,000+ entries. I'm guessing that this will have to be entered in the LDAP server entry by entry.
    I need to know how to setup the server and what settings need to be on the clients' computers, such as in Address Book.
    The server is an older G4 tower and I've got 8 computers hooked up to it on a simple network. I don't think I'll need to make the LDAP server accessible from outside the network but it's something I'll have to worry about for the future.
    Thanks for any help you can offer.

    bump

  • Spotlight search for Address Book contact results in import query?

    This bug is happening frequently lately, wheby I perform a Spotlight seach for a contact that is in my Address Book, and then when I select the contact in the search results, Address Book is selected and the app asks me "Are you sure you want to import 1 card?"
    Anybody ever see this problem or how to resolve it?
    Thanks.

    Peter, that is not a solution -- try selecting the same contact again from spotlight and you'll get the same "Import" dialog box, asking you what you want to do. 
    The expected behavior from Address Book is to open the existing contact.
    No other application does this from Spotlight that I'm aware of, and after 7 years of OS X, this is still very, very annoying.
    I wish there were a fix -- I'm activley looking and will report back.

  • Web interface for Address Book?

    Does anyone know of a web interface that is already installed or can be installed for the Address Book like the calendar and webmail have?

    take a look at
    http://vcardphp.sourceforge.net/

  • Is there a download for address book.

    I deleted address book from our G3 because it wasn't being used. But would like to get it back because we are getting a .Mac account with a new Imac next month. We want to be able to use Address Book with .Mac on both computers.
    1. I ran spotlight and didn't find it.
    2. I could not find just an Address Book download.
    3. I upgraded to 10.3.9. combined and ran spotlight again. This time I found an application but it did not have the correct icon. It had an application icon and would not open.
    4. I don't want to try and upgrade to Tiger (only 128mb & $$).
    Any suggestions?
    Thanks

    Use Pacifist to extract Address Book from the Mac OS X installation disks and install it in /Applications/.
    If the version of the system software on your installation disks is earlier than what you're using now (and only in that case), then you must also reinstall the Combo Update for the type of computer and the version of Mac OS X you're using, to bring Address Book back in sync with the rest of the system:
    Mac OS X 10.3.9 Combo Update

  • Custom layouts for Address book - plugins? utilities?

    I checked out Dr. Mac's site (I think that was the name) instructions on creating custom layouts which will also work with address book. It didn't help since I want to design my own layout and be able to preview it in address book. Unfortunately that feature doesn't seem to exist (unless I've missed it) so I'd like to find either a utility or plugin that allows me to do this within address book. I want to set the column widths, the widths between each column, where to put the page number etc.
    Your comments and/or suggestions would be most welcome.
    Thanks.

    Eve Elberg wrote:
    That's the problem. I want to extend address books capabilities so that I CAN do all those things.
    you can't. there is nothing like this in address book. no plugins or 3rd party tools for this either. and I don't understand what you really mean by a custom layout when talking about address book. address book just lists addresses. you can customize which fields and address book entry can have but that's it.

Maybe you are looking for