r/visualbasic • u/[deleted] • Feb 11 '20
Question from a Newbie
So at my new job I'm being asked to use things I never studied in school, such as some light programming stuff. So here's my question!
So say I have hundreds of word documents spread about in different files. These word documents all contain the same type of information just applied to different "objects" if you will. For example for object A there is a bunch data along with a word document in the in object A's file. Same goes for object B, C, D and so on. Is there any type of code I could write in VBA that could compile just the word documents in one file? Obviously i could just do this manually but their are hundreds of files.
Thanks!
1
u/WelcomeChristmas Feb 12 '20
Parse them with Microsoft.Office.Interop.Word and put the relevant data in a datatable then write to a new document.
1
u/thudly Feb 12 '20
Word saves all the text in binary format, with all the paragraph and font information embedded. Pretty sure it's encrypted, too. I suppose it's possible, but you'd have to hack into the word file format and manipulate all the binary data, and that would probably take longer than just merging the files by hand.
One solution would be to open every document, Ctrl+C, Ctrl+V them into notepad and save them as text. Then you can manipulate the files with simple text functions.