|

|  How to Integrate Microsoft Azure Cognitive Services with Microsoft Excel

How to Integrate Microsoft Azure Cognitive Services with Microsoft Excel

January 24, 2025

Learn how to seamlessly integrate Azure Cognitive Services with Excel for enhanced data analysis and AI-powered insights in this step-by-step guide.

How to Connect Microsoft Azure Cognitive Services to Microsoft Excel: a Simple Guide

 

Set Up Your Azure Cognitive Services Account

 

  • Log in to the Microsoft Azure Portal. If you don't have an account, create one.
  •  

  • Navigate to "Create a resource" and search for "Cognitive Services". Select it and click "Create".
  •  

  • Fill out the necessary details, like Subscription, Resource Group, and the Resource Name. Ensure you select the appropriate pricing tier and region.
  •  

  • After creation, navigate to the resource and find your "Key" and "Endpoint" – you'll need these for integration.

 

Prepare Microsoft Excel for Integration

 

  • Open Microsoft Excel and navigate to the "Developer" tab. If it's not visible, enable it from File > Options > Customize Ribbon > Check "Developer".
  •  

  • Visual Basic for Applications (VBA) will be used to run scripts, so ensure your Excel is ready to run macros.
  •  

  • Set up a worksheet where you'll input data you want to analyze with Azure Cognitive Services.

 

Create a VBA Script to Access Azure

 

  • In Excel, under the "Developer" tab, click "Visual Basic" to open the VBA editor.
  •  

  • In the editor, select "Insert" > "Module" to create a new module.
  •  

  • Paste the following VBA code into the module, replacing placeholders with your specific Azure details:

 

Sub CallAzureCognitiveService()
    Dim AzureKey As String
    Dim AzureEndpoint As String
    Dim Request As Object
    Dim JsonResponse As String
    Dim InputText As String
    
    AzureKey = "YOUR_AZURE_KEY"
    AzureEndpoint = "YOUR_AZURE_ENDPOINT"
    
    ' Example input
    InputText = Worksheets("Sheet1").Range("A1").Value
    
    Set Request = CreateObject("MSXML2.XMLHTTP")
    
    With Request
        .Open "POST", AzureEndpoint & "/text/analytics/v3.0/sentiment", False
        .setRequestHeader "Ocp-Apim-Subscription-Key", AzureKey
        .setRequestHeader "Content-Type", "application/json"
        .send "{""documents"":[{""id"":""1"",""text"":""" & InputText & """}]}"
        JsonResponse = .responseText
    End With
    
    MsgBox "API Response: " & JsonResponse
End Sub

 

  • Change the string concatenation to match the specific type of Cognitive Service you are using.

 

Test the VBA Script

 

  • Return to Excel, and in the "Developer" tab, click on "Macros".
  •  

  • Select "CallAzureCognitiveService" and click "Run".
  •  

  • Ensure you have some input in cell A1 (or adjust the VBA code to point to another cell) to analyze.

 

Interpret API Responses

 

  • Review the MsgBox output to understand the response from Azure. This output can include sentiment analysis, key phrase extraction, etc.
  •  

  • Based on this output, consider automating further analysis or result storage in your Excel worksheet.

 

Secure and Optimize Integration

 

  • Ensure your Azure Key is stored securely. Consider encrypting it with VBA or fetching it from a secure location.
  •  

  • Monitor Azure usage to manage your costs and ensure efficiency.
  •  

  • Consider using batch requests if you plan to analyze large datasets to reduce the number of HTTP requests.

 

Omi Necklace

The #1 Open Source AI necklace: Experiment with how you capture and manage conversations.

Build and test with your own Omi Dev Kit 2.

How to Use Microsoft Azure Cognitive Services with Microsoft Excel: Usecases

 

Automated Sentiment Analysis for Customer Feedback

 

  • Integrate Cognitive Services with Excel: Use Microsoft Azure Cognitive Services, specifically the Text Analytics API, to process and evaluate customer feedback data stored in Microsoft Excel spreadsheets.
  •  

  • Analyze Feedback Data: Automatically extract sentiment from customer comments and reviews by exporting customer feedback from Excel to Azure. This can provide insights into customer satisfaction and identify areas for improvement without manual data entry.
  •  

  • Display and Visualize Results: Import sentiment analysis results back into Excel. Utilize Excel’s powerful charting and graphing tools to visually represent the sentiment scores, allowing stakeholders to easily interpret the data through dashboards and reports.
  •  

  • Create Actionable Insights: Enable auto-flagging of negative sentiment feedback that needs urgent attention. Set up conditional formatting in Excel to highlight these entries, allowing customer service teams to prioritize follow-up actions efficiently.
  •  

  • Improve Decision Making: Integrate quantitative sentiment analysis into Excel-driven reports to enhance decision-making processes in areas such as product development, marketing strategies, and customer support enhancements.

 

// Sample code to integrate Azure Cognitive Services with Excel via JavaScript
const axios = require('axios');

// Function to send request to Text Analytics API
async function getSentimentFeedback(feedbackText) {
  const endpoint = "https://<your-resource-name>.cognitiveservices.azure.com/";
  const key = "<your-key>";

  const response = await axios.post(endpoint + "text/analytics/v3.1/sentiment", {
    documents: [{ id: "1", language: "en", text: feedbackText }]
  }, {
    headers: { 'Ocp-Apim-Subscription-Key': key }
  });

  return response.data;
}

 

 

Intelligent Document Processing for Business Reports

 

  • Integrate Cognitive Services with Excel: Utilize Microsoft Azure Cognitive Services, specifically the Form Recognizer API, to automatically extract and process data from scanned business reports and documents, importing this data seamlessly into Microsoft Excel for analysis.
  •  

  • Automate Data Extraction: Leverage Form Recognizer to identify key information and fields from financial statements, invoices, and other structured forms. This eliminates manual data entry, improves accuracy, and speeds up processing times.
  •  

  • Data Transformation and Cleaning: Import the extracted data into Excel and use Excel's functionalities to clean and normalize the data, making it ready for analysis. This can involve tasks such as correcting inconsistent formatting or handling missing values.
  •  

  • Create Interactive Dashboards: Use Excel’s PivotTables and graphing tools to build interactive dashboards and reports. This enables visualization of the processed data, providing insightful visuals that aid stakeholders in understanding trends and patterns swiftly.
  •  

  • Enhance Business Forecasting: Integrate the processed data into more complex Excel functions and analytics tools, allowing for precise business modeling and forecasting. This supports informed decision-making processes concerning financial budgeting, resource allocation, and strategic planning.

 

// Sample code to integrate Azure Form Recognizer with Excel via JavaScript
const axios = require('axios');

// Function to send request to Form Recognizer API
async function analyzeDocument(documentUrl) {
  const endpoint = "https://<your-resource-name>.cognitiveservices.azure.com/";
  const key = "<your-key>";

  const response = await axios.post(endpoint + "formrecognizer/v2.1/layout/analyze", {
    source: documentUrl
  }, {
    headers: { 
      'Ocp-Apim-Subscription-Key': key,
      'Content-Type': 'application/json'
    }
  });

  return response.data;
}

 

Omi App

Fully Open-Source AI wearable app: build and use reminders, meeting summaries, task suggestions and more. All in one simple app.

Github →

Order Friend Dev Kit

Open-source AI wearable
Build using the power of recall

Order Now

Troubleshooting Microsoft Azure Cognitive Services and Microsoft Excel Integration

How do I connect Microsoft Azure Cognitive Services to Excel for data analysis?

 

Connect Azure Cognitive Services to Excel

 

  • Go to the Azure Portal, and create or select your Cognitive Service instance. Obtain the API key and endpoint URL under the Keys and Endpoint section.
  •  

  • In Excel, go to the Data tab, then click on Get Data > From Other Sources > From Web.
  •  

  • In the URL field, input your Azure endpoint URL, set up a GET request as per your service documentation, and add your API key header.

 

Example: Text Analytics in Excel

 

  • Use the Postman app to test your request with the Text Analytics API endpoint and key, and note the request parameters.
  •  

  • Translate the successful Postman request into Excel by utilizing Power Query M language. Use the Advanced Editor to input your query.

 


let
    url = "https://[Your-Region].api.cognitive.microsoft.com/text/analytics/v3.0/sentiment",
    apiKey = "YOUR_API_KEY",
    body = Json.FromValue([documents=List.Transform(DocumentData, each [id=Text.From(Record.Field(_, "id")), text=Record.Field(_, "text")))]),
    response = Web.Contents(url, [Headers=[#"Ocp-Apim-Subscription-Key"=apiKey, #"Content-Type"="application/json"], Content=body])
in
    response

 

Analyze Results

 

  • After importing data, apply transformations and analyses using Excel’s built-in tools to gain insights.

 

Why is my Azure Cognitive Services API key not working in Excel?

 

Check API Key Validity

 

  • Ensure the API key is active and has not expired. Verify this in the Azure Portal.
  •  

  • Ensure you are using the correct key for the specific Azure Cognitive Service you're accessing.

 

Verify Endpoint URL

 

  • Ensure you are using the right endpoint URL; mismatch will result in failed requests.

 

Proper Authorization Header

 

  • Excel script needs to include the `Ocp-Apim-Subscription-Key` header with your API key. Check this syntax:

 


let xhr = new XMLHttpRequest();  
xhr.open("POST", url, true);  
xhr.setRequestHeader("Ocp-Apim-Subscription-Key", key);  

 

Network and Firewall Settings

 

  • Ensure that your network or firewall settings do not block external API requests.

 

Regional Restrictions

 

  • Verify that your API key's region matches the region setting used in Excel script.

 

How can I visualize Azure Cognitive Services output in Excel charts?

 

Connect Azure to Excel

 

  • Create an account in Azure and get access keys for Cognitive Services.
  •  

  • Collect data using Azure SDKs or REST API and export it to a CSV file.
  •  

  • Import the CSV to Excel by navigating to Data > Get External Data > From Text/CSV and selecting your file.

 

Prepare Data for Visualization

 

  • Clean the data by removing irrelevant rows and columns.
  •  

  • Ensure that the data columns are formatted correctly (e.g., as numbers or dates).

 

Create Excel Charts

 

  • Highlight the dataset you want to visualize.
  •  

  • Choose Insert from the Ribbon, then select a chart type like Line Chart, Pie Chart, etc.

 

Automate with Excel’s POWERQUERY

 

Sub GetAzureData()
    With ActiveSheet.QueryTables.Add(Connection:="URL;http://your_rest_api_url", Destination:=Range("$A$1"))
        .RefreshStyle = xlInsertEntireRows
        .TextFilePlatform = xlWindows
        .Refresh
    End With
End Sub

 

Apply Custom Data Visualization

 

  • Use conditional formatting for data insights.
  •  

  • Employ Excel's pivot tables for an enhanced view.

 

Don’t let questions slow you down—experience true productivity with the AI Necklace. With Omi, you can have the power of AI wherever you go—summarize ideas, get reminders, and prep for your next project effortlessly.

Order Now

Join the #1 open-source AI wearable community

Build faster and better with 3900+ community members on Omi Discord

Participate in hackathons to expand the Omi platform and win prizes

Participate in hackathons to expand the Omi platform and win prizes

Get cash bounties, free Omi devices and priority access by taking part in community activities

Join our Discord → 

OMI NECKLACE + OMI APP
First & only open-source AI wearable platform

a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded

OMI NECKLACE: DEV KIT
Order your Omi Dev Kit 2 now and create your use cases

Omi Dev Kit 2

Endless customization

OMI DEV KIT 2

$69.99

Make your life more fun with your AI wearable clone. It gives you thoughts, personalized feedback and becomes your second brain to discuss your thoughts and feelings. Available on iOS and Android.

Your Omi will seamlessly sync with your existing omi persona, giving you a full clone of yourself – with limitless potential for use cases:

  • Real-time conversation transcription and processing;
  • Develop your own use cases for fun and productivity;
  • Hundreds of community apps to make use of your Omi Persona and conversations.

Learn more

Omi Dev Kit 2: build at a new level

Key Specs

OMI DEV KIT

OMI DEV KIT 2

Microphone

Yes

Yes

Battery

4 days (250mAH)

2 days (250mAH)

On-board memory (works without phone)

No

Yes

Speaker

No

Yes

Programmable button

No

Yes

Estimated Delivery 

-

1 week

What people say

“Helping with MEMORY,

COMMUNICATION

with business/life partner,

capturing IDEAS, and solving for

a hearing CHALLENGE."

Nathan Sudds

“I wish I had this device

last summer

to RECORD

A CONVERSATION."

Chris Y.

“Fixed my ADHD and

helped me stay

organized."

David Nigh

OMI NECKLACE: DEV KIT
Take your brain to the next level

LATEST NEWS
Follow and be first in the know

Latest news
FOLLOW AND BE FIRST IN THE KNOW

thought to action

team@basedhardware.com

company

careers

events

invest

privacy

products

omi

omi dev kit

personas

resources

apps

bounties

affiliate

docs

github

help