Error while executing custom word activity

I am trying to get all the comments and related text from a word document. The code compiles correctly, but when I execute from Studio, I am getting below Error. I am able to put the code in console application and able to get desired output.

How do I debug this scenario? Is there a way I can call the method like how studio calls?
Attaching code for reference (53.5 KB)


Main has thrown an exception

Message: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

Source: Comments extract

Exception Type: COMException

System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
at Microsoft.Office.Interop.Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument, Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible, Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform)
at CommentsExtract.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Line 33:
Document document = ap.Documents.Open(FilePath);

Try with:
Document document = ap.Documents.Open(FilePath.Get(context));

You’re passing an InArgument<string> type where string is expected.

My bad, Thanks a lot :smiley: :smiley: