Take the 2-minute tour ×

Summary: I have to fill reports in excel and then manually copy the same in doc as required by my seniors to track bugs in different applications. The excel and doc report is different for every application. So I want to save work as I fill a excel and export it in the agreed template in word.

Problem : I am trying to write a macro which will search some variables in pre-defined template (doc) and replace these variables with data from excel. The variables are nothing but some text like <-AppName->, <-AppID-> (self created). Now there is a twist as there is one sheet in excel which has issues marked as high medium and low. I want to export this list to same doc as three different tables marked as high medium and low.

Question: How to populate variables (as above) in doc using the data from excel via VBA? If at all I can populate variables how do I manage to export the data from excel to doc in three different tables since it will have multiple lines.

Thanks in advance.

share|improve this question
add comment

1 Answer

I haven't gone in-depth to look at this but I don't see why it wouldn't work.

1) Set up your library references in your VBA project so you can access Word's VBA API.
2) In Excel VBA method, set up an array of your search/replacements.
3) In that same module, open the Word file(s) and replace the variables. Like I said I haven't fiddled around with the API so I can't say if you can do this easily...but also check this out.
4) Save the word documents as new files, close them.

I'm not sure what you mean "three different tables" but once you figure out how to find/replace that part should be a breeze.

share|improve this answer
add comment

Your Answer


