web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Read excel attachment ...
Power Automate
Answered

Read excel attachment with office scripts

(0) ShareShare
ReportReport
Posted on by 36

Hello,

I'd like to be able to read a specific cell (for example, cell J8) from an excel file that I am periodically receiving as attachment to an e-mail (coming from outside my organisation, prepared by others with a pre-defined template). This is because the value of cell J8 changes depending on the excel I receive via e-mail.

The excel file I'm receiving has no "format as table" style and cannot be modified on the fly (because then it's used by other functions in my company).

 

I'm wondering if this can be done via Office Scripts somehow... can anybody suggest if it's feasible?

Thank you very much.

Categories:
I have the same question (0)
  • Yutao Huang Profile Picture
    Microsoft Employee on at

    The "Run script" action only works with Excel workbooks stored on SharePoint or OneDrive for Business. So your flow will need to first save that attachment to a place on SharePoint or OneDrive for Business. But after that, you should be able to write up some scripts to read that cell value and return to the next action in your flow.

     

    These articles might be helpful:

    Save Office 365 email attachments to specified OneDrive for Business folder | Microsoft Power Automate

    Return data from a script to an automatically-run Power Automate flow - Office Scripts | Microsoft Docs

     

  • cvig Profile Picture
    36 on at

    Hi, thank you for the reply Yutao. However, I think that it would not work, as I cannot find the way to open an excel file from an office script written into another excel file.

    I mean: I may prepare "file1" with the office script and put it on SharePoint or OneDrive.

    Then I receive "file2" via e-mail; this file, which is the one I'd like to read automatically, does not contain any script and cannot be modified. I save "file2" into the same path of "file1". Up to this point everything is fine.

    Then, I should be able to read some content of "file2" (for example, one specific cell) having programmed the office script of "file1": is it possible? That's what I'm searching for.

     

    On the other hand, from what I see on the internet it seems that an office script can "act" only on the file where it is written. It's just self-referring to itself, but cannot be used to get data from another excel file. In other words, I need to carry out a "cross-workbook" operation.

     

    Thanks.

  • Verified answer
    Yutao Huang Profile Picture
    Microsoft Employee on at

    Hi @cvig -,

     

    Office Scripts is not "tied" to any particular workbook. It's stored separately on user's OneDrive for Business and it can run against any workbook the user has access to (e.g., either created by the user or other people have shared with the user).

     

    So with the "Run script" action, you can pick any existing workbook from your OneDrive for Business (or SharePoint library). You can also specify a dynamic file ID, which can be passed from a preceding action so you will be able to run your script against a workbook created on the fly (for example, saved from an email attachment).

     

    Yutao_2-1635455991297.png

     

     

     

  • cvig Profile Picture
    36 on at

    Hi @Yutao ,

    What if the "workbook" created on the fly has no office script in it?

     

    I fully understand the Power Automate side of the thing I'd like to do, but I think I'm in the case you wrote about here:

    https://powerusers.microsoft.com/t5/Using-Flows/Trying-to-use-Office-Scripts-and-Flow-to-copy-from-one-workbook/td-p/687633

     

    I need to do a cross-workbook operation, because the file I receive via email and store (with Power Automate) on SharePoint has no office script in it.

    Or maybe I don't get fully the meaning of an "office script not tied to any workbook": are you saying that, in your example, you can pick the script "Build table" and select any workbook / file you like? Does it mean that once I create an office script (with excel) on SharePoint or OneDrive, then it's available in SharePoint environment no matter what the workbook I want to run the script on is?

     

    What you think about it?

     

    Thank you very much for your patience.

  • Yutao Huang Profile Picture
    Microsoft Employee on at

    @cvig - Yes, that's exactly right. Once you create an Office Script from any workbook, it will be available in the "Run script" action to run against any other workbook that you have access to.

  • cvig Profile Picture
    36 on at

    Hi @Yutao ,

    Thank you very much! Now that's clear. This is a "basis" that, I have to admit, I missed and I hadn't found in the documentation I've read to date, but I've come across just few articles on Office Scripts into Power Automate. 🙂

     

    I'll try it today!

    Thanks

  • Yutao Huang Profile Picture
    Microsoft Employee on at

    Yes! Please give it a try and let us know what you think!

  • cvig Profile Picture
    36 on at

    Hi @Yutao ,

    I tried it and that was exactly what I was looking for (but didn't understand from the beginning the principle of scripts not "tied" to a workbook, but "living" in the cloud environment available to any workbook once they've been written for the first time in one workbook; maybe I was still thinking in "VBA-fashion"...).

     

    Thank you again.

    Take care.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 378

#2
Valantis Profile Picture

Valantis 329

#3
David_MA Profile Picture

David_MA 283 Super User 2026 Season 1

Last 30 days Overall leaderboard