the one dimensional case is clear since $W^{1,1}$ functions have representatives that are absolutely continuous, see [1] Sec. 4.9.1. The general case can be reduced to that case:
Let $a<a_1<b_1<b$. Since $A:=\{x \in \mathbb R^d: f(x)<a_1\}$ has $\mu(A)>0$,
it has a point of density; WLOG that point is the origin. Since $D:=\{x \in \mathbb R^d: f(x)>b_1\}$ has $\mu(D)>0$,
it has a point of density; WLOG that point is $z=(0,0,\ldots,0,c)$ where $c>0$.
Find $0<r<c/3$ so that $A$ occupies at least $3/4$ of $B(0,r)$ and $D$ occupies at least $3/4$ of $B(z,r)$. Thus
$A_1:=A \cap (D-z)$ satisfies $\mu(A_1) \ge \mu B(0,r)/2$. By Theorem 2, Sec. 4.9.2 in [1], $f$ has a representative such that for a.e. $x=(x_1,\ldots,x_d)$ in $A_1$, the function
$t \mapsto f(x_1,\ldots,x_d+t)$ is absolutely continuous, and the claim follows by Fubini.
Evans, Lawrence C., and Ronald F. Gariepy. "Measure theory and fine properties of functions", CRC Press. Studies in Advances Mathematics (1992).