Using asdocx with putdocx

Since putdocx allows merging several docx files using the putdocx append command, we can generate files using asdocx with the .docx extension and then merge it with files generated by the putdocx. Below, I perform the following sequence of tasks:

(1) create a file with putdocx command (2) write some text and regression results to that file using putdocx (3) save that file (4) create another file with asdocx (5) and finally merge the asdocx file to the putdocx file.

*1 Clear putdocx file from memory, if any.
putdocx clear

*2 Load the data set
sysuse auto, clear

*3 Start the putdocx file
putdocx begin

*4 Some putdocx commands
putdocx paragraph, style(Heading1)
putdocx text ("Regression results")

* Write regression results
reg price mpg rep78 headroom trunk length
putdocx table bweight = etable, title("Linear regression of birthweight")

*5 Save the putdocx contents to a file, call it putdocxfil
putdoc save putdocx_file, replace

*6 Write summary statistics with asdocx to a file:name the file as asdocfile
asdocx sum, save(asdocx_file)

*7 Add the asdocx_file to the putdocx_file
putdocx append putdocx_file asdocx_file

The above code generates a combined file that contains the following contents.