Microsoft has overtaken Apple as the world's most valuable company for the first time in more than a year.