I need to take an Excel cell that is generated from a VBA macro (in a local excel file) and write it to a sharepoint excel file. The cell looks like this in the local file :
If the merged cell is created from a macro, then perhaps you can name the cell at the same time?
Then you dont have to know the exact coordinate of the cell.
Perhaps an alternative approach could be to make a dummy template Excel-file with the formatting you require, and then copy/paste this document to you destination after changing it.
I have previously had a similar requirement, where I would include the Excel template/file in the solution and use this as a basis for the end result.
Store output in variable, example: mergedCellValue
Get color if required
Use Get Cell Color
Cell: A1
Store in variable, example: cellColor
Open SharePoint Excel
Use Microsoft 365 Scope
Add Use Excel File
Select the SharePoint Excel file.
Write value
Use Write Cell
Cell: A1
Value: mergedCellValue
Merge the same range
Microsoft 365 Excel activities may not directly support merge cells.
Best option: use Run Script activity with Office Script.
Office Script example
In SharePoint Excel, create this script:
function main(workbook: ExcelScript.Workbook, textValue: string) {
let sheet = workbook.getWorksheet("Sheet1");
let range = sheet.getRange("A1:C1");
range.merge(false);
range.setValue(textValue);
range.getFormat().getFill().setColor("#87CEEB");
range.getFormat().setHorizontalAlignment(ExcelScript.HorizontalAlignment.center);
range.getFormat().setVerticalAlignment(ExcelScript.VerticalAlignment.center);
}
Call Office Script from UiPath
Use Run Script activity inside Microsoft 365 Excel.
Select this script.
Pass mergedCellValue as input parameter.