VBA & Macro Problems

How to Fix Base64 Images Not Inserting into Excel via Office Scripts

Rana GarciaRana Garcia Nov 10, 2026 869 views

Question details

The user needs to insert Base64 signature images originating from Power Apps into an Excel worksheet via Office Scripts and Power Automate.

Fix Base64 Images Not Inserting into Excel with Office Scripts
Product
Microsoft Excel
Device & OS
not provided
Scenario
Transferring Base64 image strings from Power Apps to Excel using Power Automate and Office Scripts.
Observed behavior
The Base64 image fails to insert into the worksheet when passed directly through Power Automate, even though hardcoded Base64 strings work perfectly in the script.
Before you start

Ensure you have access to both the Power Automate flow and the target Excel file. Verify that the Base64 string generated by Power Apps is complete and not corrupted before sending it to Excel.

Solution 1Recommended

Store Base64 Strings in a Hidden Worksheet

Bypass direct parameter passing limitations by writing the Base64 string to a cell first, then retrieving it within the Office Script.

Passing extremely long Base64 strings as direct parameters from Power Automate to an Office Script can sometimes cause formatting or truncation issues. Storing the string in a temporary Excel cell acts as a reliable bridge for the data.

1
Update the Power Automate Flow

Modify your flow to write the Base64 string into a specific cell (e.g., A1) on a hidden or temporary worksheet, instead of passing it as a parameter in the 'Run script' action.

2
Modify the Office Script

Use the getRange().getText() method to retrieve the Base64 string from the temporary cell within your script. For example: let base64String = workbook.getWorksheet('TempSheet').getRange('A1').getText();

3
Call the Add Image Method

Pass the retrieved text string into the addImage() method to render the image on the desired worksheet.

4
Clean Up the Temporary Data

Add a final step in your script to clear the contents of the temporary cell using getRange().clear() after the image is successfully inserted.

Store Base64 Strings in a Hidden Worksheet
Reliable Transfer: This method effectively avoids the data truncation and parsing errors that frequently occur when Power Automate handles massive Base64 strings.
Free Microsoft Office alternative

Looking for a simpler way to automate spreadsheets? Try WPS Office

If complex Power Automate flows and cloud-based Office Scripts are causing workflow bottlenecks, consider WPS Office. It offers a powerful built-in JS Macro editor and excellent VBA compatibility for automating spreadsheet tasks without relying on external cloud connectors.

  1. 1. Download and Install WPS Office: Get the free WPS Office suite from the official website and install it on your computer.
  2. 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing .xlsx files with full format retention.
  3. 3. Access the Macro Editor: Navigate to the 'Tools' tab and click on 'Macros' or 'JS Macro' to write and execute your automation scripts locally.
Fully compatible with Microsoft Excel (.xlsx, .xls, .csv) formats.Built-in JS Macro and VBA support for robust, local spreadsheet automation.Lightweight, fast, and free to use without complex cloud setups.Intuitive interface with seamless transition from Microsoft Office.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Office Script work with a hardcoded Base64 string but fail in Power Automate?

Power Automate may truncate or improperly escape extremely long Base64 strings when passing them directly as script parameters. Storing the string in an Excel cell first circumvents this cloud-transfer limitation.

Do I need to include the data URI prefix (e.g., data:image/png;base64,) in my string?

No, the addImage() method in Office Scripts generally expects only the raw Base64 string data. Ensure you strip the data URI prefix before passing the string to the script.

How can I hide the worksheet used for transferring Base64 data?

You can manually right-click the worksheet tab in Excel and select 'Hide', or you can use an Office Script command like workbook.getWorksheet('Temp').setVisibility(ExcelScript.SheetVisibility.hidden); to keep it hidden automatically.