Hi,
I am trying to create several word documents containing some text, data, and pictures, I am doing this using a loop but am running into issues where putdocx is not running in the loop, but runs fine on its own.
Here is an example of the code I am running.
version 16
global list au rf rr
foreach l of global list {
putdocx clear
putdocx begin
putdocx paragraph, style(Title)
putdocx text ("My document about `l'")
putdocx textblock begin, paramode
This is the block of text I am trying to insert.
putdocx textblock end
putdocx save "myfile_`l'.docx"
}
When I run this I get an error saying "unrecognized command 'This'" and upon tracing the program it seems the problem is that the line "putdocx textblock begin, paramode" is not running, but the previous putdocx commands ran successfully.
However, if I run the code inside the loop like so:
local l au
putdocx clear
putdocx begin
putdocx paragraph, style(Title)
putdocx text ("My document about `l'")
putdocx textblock begin, paramode
This is the block of text I am trying to insert.
putdocx textblock end
putdocx save "myfile_`l'.docx"
Then the code runs through just fine.
Does anyone have any ideas why that particular putdocx command would not execute in the loop but would run just fine outside of it?
Thanks,
Robert
Related Posts with Putdocx in a loop
"Nothing to restore" error when using parmby.Hello everyone, I am a new beginner of Stata. I tried to run a stata code written by an author whose…
Quantile regression (multilevel data)Good morning. I wanted to ask if anyone can help me and give me information about which commands I …
Problem with using marginsDear statalist I have a problem using margins on stata command. I'm doing some research related to …
Export Summary Stats with variable labels using putexcelHi Statalisters! I am trying to make the most of stata16's new automated reporting functions, and p…
Remaining heteroskedasticity even after using GARCH(1,1)I've also tried GARCH(1,2) and GARCH(2,1) but both of the residuals are subject to arch after testin…
Subscribe to:
Post Comments (Atom)
0 Response to Putdocx in a loop
Post a Comment