Inserting the data to word table


#1

hi In this artifact it Inserts the data
to word file table dynamically without using any bookmarks…
insert table.zip (17.9 KB)


How to copy&paste a table from Excel to Word document
#2

Hi @sanjay21051990

Thanks for this, exactly what I needed. However, do you have a method of saving the document to a certain path? I have tried to invoke the method SaveAs from from the namespace, but I am struggling… Any help is much appreciated :slight_smile:

Edit: It seems that the invoke method activity does not recognise any of the methods from the Microsoft.Office.Interop.Word namespace… Anyone know how to fix this?


#3

Hi @nbjerke,
If your file is originally stored in another folder, you can use the activity Copy File. All you need to do is to place the full paths in “From Path” and “To Destination” (including the file name in both cases e.g. “C:\Users\Desktop\reading test.xlsx”). Alternatively, you can start your work with creating that required file in the place you need with “Create file” activity, where again - the “Path” field is sufficient to give your file the desired format and destination. Hope that helps somehow.


#4

Thanks for the response, I will give it a try. However, I am really trying to build on the project that @sanjay21051990 posted. Did you look at that at his project?


#5

Yeah, and I can see that there is a default file path mentioned in the variable InputFile “d:\Doc1.docx”. Can you play with that value?


#6

The input filepath is the template that I am using, but the process opens up a new document and copies the data into it. Thats why I need to save the new document.

edit: I changed the assignement of wordDoc to wordApp.Documents.Open(inputFile) and now it opens the document template and not a new file, but I am still unsure how to save the changes I have made to the document :persevere:


#7

Sorry, you are right, I have re-looked into the original automation again, and what works for me is adding under ‘While’ activity ‘Send hotkey F12’ and then ‘Type into’ where you give your designated file path with ‘Enter’ key - e.g. “C:\Users\Desktop\insert table\doc1.docx[k(enter)]”.
save%20file Does this help?


#8

Yes it is a workaround, but I would really like to solve it more programmatically, without out having to open word…


#9

Well, here comes the difference - when I run that automation, it does open word docs for me and leaves then open…


#10

I figured it out, I just needed to convert the wordDoc type to Microsoft.Office.Interop.Word.DocumentClass and the method worked. Refer to this post.

If you want Word not to open change the assignment of wordApp.Visible = False :slight_smile:


#11

Glad that you have found the solution :slight_smile:


#12

hi use below approach using invoke code :slight_smile:
insert table.zip (18.5 KB)