Error while executing custom word activity

activities
studio
custom_activities

#1

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

WordcommentsExtract.zip (53.5 KB)

EXCEPTION MESSAGE

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)


#2

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.


#3

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