That doesn’t always work. For example, my brothers will compliment me if I look particularly nice that day or have a new outfit. “You look nice!” Or “Is that a new dress? It’s pretty.” is completely appropriate. Many women I work with would NOT find a comment like this from a man as appropriate, and they would consider it as creepy, and probably harassment. I even had a coworker complain about someone to me until I pointed out that he also compliments men on nice shoes, sweaters, etc… I think he just appreciates nice clothes!
So there is the obvious way of treating women with respect, but I can understand how a lot of men may be nervous about the seemingly appropriate/mundane things they may say or do, and how a woman might interpret it.