How can I write in a box with fixed height?

Use in the definition of \makenonemptybox the same method you use for \framebox to close current paragraph. Of course, that will restrict its usage to list environments.

\documentclass[a4paper,11pt]{report}

\newcommand{\makenonemptybox}[2]{%
%\par\nobreak\vspace{\ht\strutbox}\noindent
\item[]
\fbox{% added -2\fboxrule to specified width to avoid overfull hboxes
% and removed the -2\fboxsep from height specification (image not updated)
% because in MWE 2cm is should be height of contents excluding sep and frame
\parbox[c][#1][t]{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{
  \hrule width \hsize height 0pt
  #2
 }%
}%
\par\vspace{\ht\strutbox}
}
\makeatother

\begin{document}
\begin{enumerate}
\item Tell me about yourself.
    \begin{enumerate}
    \item What is your name?
          \makenonemptybox{2cm}{My name is Nadia.}
    \item Where are you from?
          \makenonemptybox{2cm}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam a venenatis lacus. Nunc vitae mollis neque. Maecenas vel arcu erat.}
    \item How old are you?
    \item[] \framebox[\linewidth]{\rule{0pt}{2cm}}
    \end{enumerate}
\end{enumerate}

\end{document}

enter image description here

Tags:

Box