Transfer word macro from one system to the other

Hi Team,

I have created a macro in word document and ran that macro using Uipath. Now I want to run the same script in another system. How can i get that macro in the new system.
Please help me in resolving this.

Regards,
Revathi.

1 Like

Hey @revathineelima,

Just have that macro file inside UiPath project.

So whenever you publish the project and run in different machines. It can able to run the same macro again.

Hope this helps.

Thanks :slight_smile:

Hi @Nithinkrishna

Thanks. From where will i get that macro file

Regards,
Revathi

1 Like

Hey @revathineelima,

You need to create a separate .vbs file with macro code instead of creating inside word application.

Keep that file inside the project folder & execute the same macro in the required file.

Thanks :slight_smile:

@Nithinkrishna

Sorry i did not get you. Can you please explain again.

Thanks

1 Like

No problem :slight_smile: @revathineelima,

Currently you would have created macro inside the word file…

Now I suggest you to create a separate vbscript file with macro code which you used in the word above.

This will split the resource into two - Word file & vbs file with macro code

Save vbs file inside the UiPath project folder. Whenever you execute the macro you can call that vbs file irrespective of word file or machine.

Hope this helps

Thanks :+1:

@Nithinkrishna

Thanks. I have a doubt. While invoking the script using invoke vbscript, what should i give in output.

image

Thanks

1 Like

Yep @revathineelima,

Output field is not mandatory.

It’s based on the vbs script providing output or not.

If your script generates any output you can capture by passing a variable to the output field.

Hope this helps

Thanks :slight_smile:

Hi @Nithinkrishna

Thanks for the solution. Just one thing. Below bold.docx is the word document and i have a screenshot in it. I need to add border for the screenshot. So i have added script to add border.

image

Could you please confirm how can i link word document with VBScript.

Thanks,
Revathi

1 Like

Yes this should work !

@Nithinkrishna
But changes are not getting reflected. I think i am missing the link. Below is the code which i have used in VBScript

Sub Border()
Dim i As Long, j As Long
With ActiveDocument.Range
For i = 1 To .InlineShapes.Count
With .InlineShapes(i)
.Borders(1).LineStyle = wdLineStyleSingle
.Borders(1).Color = wdColorAutomatic
End With
Next i
End With
End Sub

Regards,
Revathi

1 Like

@revathineelima, This may be something related to the script.

You can first try a simple script may be just to confirm once.

Wrt the above script, You may try this document replacing active document.

Thanks :slight_smile:

@Nithinkrishna
Thanks you so much for reply.
Instead of “With ActiveDocument.Range” what can be used to include word document.

C:\Users\tatapudi_revathi\Desktop\SampleDoc.docx is the path of the document

Regards,
Revathi.

1 Like

ThisDocument may be.

First you may try like printing out the name of the active workbook in msgbox.

Hope this helps,

Cheers :slight_smile:

@Nithinkrishna

Thanks. I will try that.

Regards,
Revathi

1 Like