Call Word Macro using Ui Path

We have a scenario where we need to delete rows of a table dynamically in a word file. We have the macro query for it and is working fine when run in the word file.
But we need to run this query via UI Path. We did not find any activity in UI Path Studio related to Word macro.

Can you please help us on the same.

1 Like

Hello,
Not sure if you still have this problem, but thought I’d answer if you do. Unlike excel, there is no automatic Execute Macro function in uipath (Visual basic has it, but so far not uipath). So what I did was a combination of hotkeys.

First on the machine running the robot you need to have your macro installed under the normal.dot function.
To do this, open VBA under word and do an import file placing the macro under the normal directory. This allows the macro to be available to any word application running on that PC

In uipath in the word application scope:
‘send hotkey’ of ALT-F8 (this opens the macro window)
‘Run Select item ‘list’’ with your macro name

Do a Click ‘push button’ to run OK

This worked for me better then trying to work my way through the Word menu system.

I wouldn’t say this is a straightforward way to do it… But one thing you could try is to invoke some VBA code in excel, and in excel add a reference to word and by that get all the VBA functionality in word. Well, technically you don’t really have to add the reference, but writing the code is a bit easier if you do.

I have done this with Power Point and it has worked out pretty well. The following VBA code is run by invoking it in an excelfile. It adds some titles to power point slides.


word%20reference

1 Like

You can run a macro in word using the open application then applying the macro thru arguments



the boxed one is opening the word file and the name of macro is “JaysonCommand”

Hi @sarika2010

Actually, there is an activity to invoke a VBScript :slight_smile:
image

I think it was introduced with the UiPath.System package 19.6.0.

Hi all,

Here is the simple solution to execute the macro.

Regards
Balamurugan.S

1 Like