How to read table in a Word document

@Kusum_R if there is an activity where you can pass the file path and Table number (1 or 2 or 3) and get comma saperated string as output? Will that help you?

As a last resort, you may create a custom activity (if it is very important)

namespace WordTable
{
    public class WordTable : CodeActivity
    {
        [Category("Input")]
        [RequiredArgument]
        public InArgument<string> FilePath { get; set; }

        [Category("Input")]
        [RequiredArgument]
        public InArgument<int> TableNumber { get; set; }

        [Category("Output")]
        public OutArgument<Word.Table> Output { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            Word.Application wordApp = new Word.Application();
            object filename = FilePath.ToString();
            object missing = Type.Missing;
            Word.Document doc = wordApp.Documents.Open(ref filename, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
            Word.Table table = doc.Tables[int.Parse(TableNumber.ToString())]; //define this index depending on the number of table which you want to get
            doc.Close(ref missing, ref missing, ref missing);
            Marshal.ReleaseComObject(wordApp);

            Output.Set(context, table);
        }

    }
}
2 Likes