Let $a$, $b$, $c$ be the three roots of the equation $x^3-(k+1)x^2+kx+12=0$, where $k$ is a real number. If $(a-2)^3+(b-2)^3+(c-2)^3=-18$, find the value of $k$.
1. **Using Vieta's formulas**: Given the polynomial equation \(x^3 - (k+1)x^2 + kx + 12 = 0\), the roots \(a, b, c\) satisfy:
   \[
   a + b + c = k + 1
   \]
   \[
   ab + ac + bc = k
   \]
   \[
   abc = -12
   \]

2. **Expanding the given condition**: We are given \((a-2)^3 + (b-2)^3 + (c-2)^3 = -18\). Expanding each term using the binomial theorem:
   \[
   (a-2)^3 = a^3 - 6a^2 + 12a - 8
   \]
   \[
   (b-2)^3 = b^3 - 6b^2 + 12b - 8
   \]
   \[
   (c-2)^3 = c^3 - 6c^2 + 12c - 8
   \]
   Adding these, we get:
   \[
   (a-2)^3 + (b-2)^3 + (c-2)^3 = a^3 + b^3 + c^3 - 6(a^2 + b^2 + c^2) + 12(a + b + c) - 24
   \]
   Given that this sum equals \(-18\), we have:
   \[
   a^3 + b^3 + c^3 - 6(a^2 + b^2 + c^2) + 12(a + b + c) - 24 = -18
   \]

3. **Simplifying the equation**: Rearrange the equation:
   \[
   a^3 + b^3 + c^3 - 6(a^2 + b^2 + c^2) + 12(a + b + c) - 24 = -18
   \]
   \[
   a^3 + b^3 + c^3 - 6(a^2 + b^2 + c^2) + 12(a + b + c) = 6
   \]

4. **Using known identities**: We know from algebraic identities:
   \[
   a^2 + b^2 + c^2 = (a + b + c)^2 - 2(ab + ac + bc)
   \]
   Substituting the values from Vieta's formulas:
   \[
   a^2 + b^2 + c^2 = (k + 1)^2 - 2k = k^2 + 2k + 1 - 2k = k^2 + 1
   \]

5. **Finding \(a^3 + b^3 + c^3\)**: Using the identity for the sum of cubes:
   \[
   a^3 + b^3 + c^3 = (a + b + c)(a^2 + b^2 + c^2 - ab - ac - bc) + 3abc
   \]
   Substituting the known values:
   \[
   a^3 + b^3 + c^3 = (k + 1)(k^2 + 1 - k) + 3(-12)
   \]
   \[
   a^3 + b^3 + c^3 = (k + 1)(k^2 - k + 1) - 36
   \]
   \[
   a^3 + b^3 + c^3 = k^3 + 1 - 36 = k^3 - 35
   \]

6. **Substituting back into the expanded condition**:
   \[
   k^3 - 35 - 6(k^2 + 1) + 12(k + 1) = 6
   \]
   Simplifying:
   \[
   k^3 - 35 - 6k^2 - 6 + 12k + 12 = 6
   \]
   \[
   k^3 - 6k^2 + 12k - 29 = 6
   \]
   \[
   k^3 - 6k^2 + 12k - 35 = 0
   \]

7. **Solving the cubic equation**: Testing possible rational roots, we find:
   \[
   k = 5
   \]
   Substituting \(k = 5\) into the cubic equation:
   \[
   5^3 - 6 \cdot 5^2 + 12 \cdot 5 - 35 = 125 - 150 + 60 - 35 = 0
   \]
   Thus, \(k = 5\) is a solution.

The final answer is \(\boxed{5}\).