Invoke code activity throwing error in server

Hi Community,
i have used this code
Dim objWord As New Microsoft.Office.Interop.Word.Application

’ Get the file path of the Word document
Dim filePath As String = v_FilePath ’ Replace with the path to your Word document

’ Open the Word document
Dim objDoc As Microsoft.Office.Interop.Word.Document = objWord.Documents.Open(DirectCast(v_FilePath, Object))

’ Execute the macro
objWord.Run(“ShiftHeadingsAndParagraphsToNewPage”)

’ Save and close the document
objDoc.Save()
objDoc.Close()

’ Quit the Word application
objWord.Quit()
to run macro in word using invoke code activity in UiPath, it is working perfectly in my system ,but when i run this code in client server it is throwing error
“Invoke Code: Exception has been thrown by the target of an invocation.”, what is the reason for this, do i need to change any settings, please help me to rectify the issue.
Regards,
Alan

@alan.prakash

  1. Does the client machine has word installed and is licensed?
  2. Better log the exception.Stacktrace or exception.innerexception , these would give that error is occuring in invoke code
  3. Other option is use try catch in invoke code and write the exception as this does nto say what exception occured

cheers