0

I need to have an office add-in component (https://dev.office.com/getting-started/addins ) to allow user to select a contact from the global address book to insert that contact email in the word document.

Any suggestions if this can be done with office add-ins? if yes how can it be done? or it must be VSTO?

Emad Gabriel
  • 3,677
  • 7
  • 37
  • 49

1 Answers1

1

An Office Add-in is simply a web app (that happens to run in the context of an Office host), so you can design it to do the types of things that a web app can do, including issuing requests against REST APIs. Regarding the scenario you've described, I'd view it as 3 distinct tasks:

  1. Get contact info from AD.
  2. Present list of contacts to user (so they can select one).
  3. Insert email address of selected contact into document.

1- Getting contact info:

Re the specific scenario that you've described, I'd suggest that you investigate the feasibility of using either the Microsoft Graph API or the Azure Active Directory Graph API to get contact information from the GAL. Please note that, in general, using Microsoft Graph is recommended over using Azure AD Graph.

2- Presenting list of contacts to the User:

Regarding UI design, because your Office Add-in is simply a web app, you can present the list of contacts to the user in whatever manner that your web app supports.

3- Inserting text into the Word document:

Regarding inserting text into the document when the user selects a contact via the Add-in UI, you'll use the Word JavaScript API to do this. If you haven't used the Word JavaScript API before, I'd suggest that you start by doing the Word Add-in quickstart, which shows how to insert text at various points in a document. Then, for additional details about the API, see the Word JavaScript API reference docs. (Which API operation you use to insert text into the document will depend the specifics of your implementation. I'd suggest that you post a separate Stack Overflow question that describes specifically what you want to achieve re insertion of text into the document, if you need help with that when the time comes.)

Kim Brandl
  • 13,125
  • 2
  • 16
  • 21
  • Thanks for the reply. about #1: "Getting contact info:" any suggestion for getting this information from a local AD (i.e. client not using office365 or Azure AD). – Emad Gabriel Dec 25 '17 at 16:35
  • 1
    I'm not very familiar with querying AD, but perhaps these other posts might be helpful? https://stackoverflow.com/questions/14813452/connect-to-active-directory-via-ldap OR https://stackoverflow.com/questions/2780587/active-directory-on-local-server-and-intranet-on-external-server – Kim Brandl Dec 25 '17 at 21:30