How can I attach to an already open Microsoft Word application using Invoke Code in C# in UiPath?

In UiPath, I want to attach to an already open Microsoft Word application using Invoke Code in C#. How can I do this so that I can control Word without opening a new instance?

@Vhierdy_Hafidz

Please check this

Cheers

i do as the solution explained.
but i still got error

Error Message:
Error ERROR Validation Error No compiled code to run
error CS0117: ‘Marshal’ does not contain a definition for ‘GetActiveObject’ At line 0 UjiCoba.xaml

@Vhierdy_Hafidz

I believe you are on windows in .net 5 the method is removed

Try this

Microsoft.Office.Interop.Word.Application wordApp = Microsoft.VisualBasic.Interaction.GetObject(null, "Word.Application") as Microsoft.Office.Interop.Word.Application;

Cheers

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.