We introduce a method for computing Hilbert decompositions  (and consequently the Hilbert depth) of a finitely generated multigraded module
$M$ over the polynomial ring $K[X_1, ldots, X_n]$ by reducing the problem
to the computation of the finite set of Hilbert partitions. We show that
Hilbert partitions may also be used for computing  the Stanley depth of
the module $M$. Thus, we provide solutions to some problems proposed by
Jurgen Herzog.