VBA code to transfer data from word to excel.

Stutrutta

New Member
Joined
Jul 4, 2019
Messages
1
Hello
I am a VBA novice but have been having a crack at the following problem but I need more expert input and assistance.
The problem is to extract information from control content field into tables and "related" and copying the information to a single row in excecl.


I am having difficulty putting together code to do the following.

VBA (activated by a button in excel - this bit is not the problem) code to go to a specific folder (ie "Project plans play") containing several project outline word documents (each with a different name).
For each word document, I want to extract the data in the content control fields and copy it into a word document (Project Breakdown).
The word documents would have the same structure with 4 content fields outlining the project (the fields are Project Name, Project Code, Project Manager, Project Priority) then below is a table with multiple rows of task information. The column headers are Project and Task Code, Task, Project Staff, Start Date, End Date, Number of Days and Milestone.
The 4 content control outline fields would be copied and written in the first four columns of the excel spread sheet and the first row of the table containing task information (ie Project and Task Code, Task, Project staff etc etc until Milestone) would be also written to the adjoining cells in the row.
The code would then get the next 4 content control field outline fields of the same document and the next row of task information in the table and copy it to excel in the next row.
The next step would be repeat the copy and writing process until the data in last row in the task table in word is copied to excel.

The code would do this for each project document in the folder. I imagine there could be 20-30 to them.

Attached is an example of the word document containing the project information and also the excel spread sheet which would receive the information.

I have seen and explored some code that grabs the information in work in content control fields and copies it to excel but I cant seem to extend this code further to copy and write additional rows of data in the word document.

Any help or code would be appreciated.
I might have chosen a difficult problem to start my learning.

Thanks.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,214,400
Messages
6,119,289
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top