Business-software company Yammer Inc. agreed to sell itself to Microsoft Corp. for $1.2 billion, according a person familiar with the matter, in a sign Microsoft may be trying to plug holes in its ubiquitous Office software.

It is unclear when the Yammer acquisition will be completed and announced, according to the person familiar with the deal.

A...