Given that in a triangle $ABC$, $AB=3$, $BC=4$ and the midpoints of the altitudes of the triangle are collinear, find all possible values of the length of $AC$.
1. **Identify the given information and the problem statement:**
   - We are given a triangle \(ABC\) with \(AB = 3\), \(BC = 4\), and we need to find the possible values of \(AC\) given that the midpoints of the altitudes of the triangle are collinear.

2. **Define the midpoints and orthocenter:**
   - Let \(D, E, F\) be the midpoints of \(BC, CA, AB\) respectively.
   - Let \(H\) be the orthocenter of \(\triangle ABC\).

3. **Use the property of collinearity of midpoints of altitudes:**
   - The midpoints of the altitudes of \(\triangle ABC\) being collinear implies that the feet of the perpendiculars from \(H\) to the sides of \(\triangle DEF\) are collinear. This means \(H\) lies on the circumcircle of \(\triangle DEF\).

4. **Relate the orthocenter and circumcircle:**
   - The midpoint of \(AH\), denoted as \(H_a\), is the orthocenter of \(\triangle AEF\) and lies on the circumcircle of \(\triangle DEF\). Similarly, define \(H_b\) and \(H_c\) for the other vertices.

5. **Conclude that \(H, H_a, H_b, H_c\) lie on a circle:**
   - Since \(H, H_a, H_b, H_c\) lie on a circle, it follows that \(H, A, B, C\) lie on a circle. This implies that \(\triangle ABC\) must be a right triangle (as the orthocenter of a right triangle lies on the circumcircle).

6. **Determine the hypotenuse using the Pythagorean theorem:**
   - Since \(\triangle ABC\) is a right triangle, we can use the Pythagorean theorem to find \(AC\).
   - Given \(AB = 3\) and \(BC = 4\), the hypotenuse \(AC\) can be calculated as:
     \[
     AC = \sqrt{AB^2 + BC^2} = \sqrt{3^2 + 4^2} = \sqrt{9 + 16} = \sqrt{25} = 5
     \]

7. **Consider the possibility of another value for \(AC\):**
   - The problem mentions \(AC = \sqrt{7}\) as another possible value. However, this does not fit the given side lengths \(AB = 3\) and \(BC = 4\) in a right triangle configuration. Therefore, this value is not valid.

Conclusion:
\[
\boxed{5}
\]