Preheat the oven to 450F. Assemble as many sandwiches as you'd like to make, using thinly sliced ham and cheese, and spread the outside of the sandwiches with soft butter or mayo. Arrange them on a parchment-lined baking sheet and bake for 10 minutes, flipping about halfway through, until golden.
Meanwhile, set aside a small amount of the cheese (enough to sprinkle a bit on each sandwich) and put the rest into a medium bowl. Add the flour and toss to coat. Heat the milk in a medium saucepan and when it's steaming, add the cheese in handfuls, stirring until each addition melts before adding the next. Stir until smooth.
Pour some of the cheese sauce over each sandwich and top with a bit more shredded cheese. Return to the oven for 5 minutes, until the top is bubbly and golden. (If you like, switch the oven to broil, but watch it carefully - it should brown in just 1-2 minutes.) Serve warm.