I inserted a merge field into my MS Word file like below:
In the output, it is seen like below:
So it doesn't render the code (if statement) but prints it out to the output. Why and how can I fix it? Thanks.
Edit: note that the curly paranthesis are created by ctrl + f9
That suggests you have Word's field code display toggled on and that you're only previewing the merge, rather than completing it. Word's field code display can be toggled on/off via Alt-F9.
Your display also indicates that the scode field outputs spaces after the number. You need to either eliminate those spaces from the data source or allow for them in the test. You can allow for them in one of two ways:
{IF{MERGEFIELD scode \# 0}= 301 "jesus" jesus2"}
or:
{IF "{MERGEFIELD scode}" = "301*" "jesus" jesus2"}