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
count in groupsHi all, I am struggling right now with following task (attached the data): I want to find the year i…
Problem with displaying multiple models using coefplot recast(bar)Dear all, I am struggeling with displaying multiple graphs with the recast(bar) option from -coefpl…
Help estimates table and Hausman testI would like to show in a table the prob>chi2 of 2 Hausman tests. Is this possible? This I am do…
Annual return from each company, wen having monthly data givenI am right now trying to generate annual return volatility for each company using the following form…
Predict fxnHi! I am running a tobit regression model in stata, and would like to calculate the practical signif…
Subscribe to:
Post Comments (Atom)
0 Response to Putdocx in a loop
Post a Comment