cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DieSeL212
Regular Visitor

Is it possible to use power automate desktop to paste a formula on excel?

A formula on multiple docs is incorrect. I'm trying to replace the incorrect one with this one  =IF(G13=$K$5;5;IF(G13=$K$6;4;IF(G13=$K$7;3;IF(G13=$K$8;2;IF(G13=$K$9;1;)))))

 

Since I am pasting a formula, I created a new variable and set its value as the formula but get an error when I run it.

 

The error is "Failed to write to excel" and includes the detail below:

 

Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: Failed to write into Excel. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.ExcelActions.SetProperty(Object o, String propertyName, Object value)
at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.ExcelActions.WriteToExcel(Variant excelInstance, Variant startCol, Variant startRow, Variant valueToWrite, Int32 writeMode)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.WriteToExcel.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelAnnis
Super User
Super User

Instead of ‘write to Excel’

 

Set to clipboard text %Formula%
Then activate the cell you want to paste in

Then Paste cells to Excel

 

Here is mine, and it worked.  Ignore the 'Replace Text', we use commas instead of semi-colons.

 

MichaelAnnis_0-1643724097874.png

Good luck!

View solution in original post

6 REPLIES 6
Henrik_M
Super User
Super User

Wrong topic. Can't delete. Disregard.

MichaelAnnis
Super User
Super User

Is this the same password protection issue as in the other post? Or are you getting this error even in an unprotected workbook?

This is on an unprotected excel file. 

MichaelAnnis
Super User
Super User

Instead of ‘write to Excel’

 

Set to clipboard text %Formula%
Then activate the cell you want to paste in

Then Paste cells to Excel

 

Here is mine, and it worked.  Ignore the 'Replace Text', we use commas instead of semi-colons.

 

MichaelAnnis_0-1643724097874.png

Good luck!

You sir are a scholar and a gentleman! That worked! Thank you!

Now, to figure a way around the protected sheet bit. 

I've heard of power query. Any ideas if that would work on the protected sheet?

Use the UI elements for File Info, and you should be able to unlock the sheet somewhere there:

 

https://support.microsoft.com/en-us/office/protect-an-excel-file-7359d4ae-7213-4ac2-b058-f75e9311b59...

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Kudoed Authors
Users online (5,213)