Quite a few of them, especially in Central and South America.
Here are lists of attempted and successful coups d'etat, listed by date in the former, by nation in the latter.
history.stackexchange.com/users/892/RI Swamp Yankee
The 1973 Pinochet coup in Chile seems to fit the criteria you outline.
A democratically elected president of a Western country ousted by the military.
The 1973 Chilean coup d'état was a watershed event of the Cold War and the history of Chile.
Following an extended period of social and political unrest between the conservative-dominated Congress of Chile and the elected socialist President Salvador Allende , Allende was overthrown in a coup d’état.
The junta was composed of the heads of the Air Force, Navy, Carabineros (police force) and the Army , though Pinochet eventually arose to supreme power within a year after the coup, formally assuming the presidency in late 1974.
Pinochet later assumed power and ended Allende's elected Popular Unity government, instigating a campaign of terror on its supporters which included the murder of former Foreign Minister Orlando Letelier.
Before Pinochet's rule, Chile had for decades been hailed as a beacon of democracy and political stability in a South America plagued by military juntas and Caudillismo.
history.stackexchange.com/users/967/Andrew Turvey
Poland - ("Zamach majowy" - May coup )
- parliamentary democracy from 1918, successful coup d'etat of Józef Piłsudski in May 1926, and then authoritarian rule of Piłsudski's party up to 1939.
history.stackexchange.com/users/1636/soliloquyy
Britain, dictatorship 1653-1658 France, absolute monarchy until 1789, then dictatorship (1799), absolute empire (1804), again monarchy (1814), then dictatorship (1848) and absolute empire again (1852). Germany, absolute monarchy (1871-1918), then dictatorship (1933) Spain, absolute monarchy before 1873, restoration of monarchy by a coup (1874-1931), dictatorship 1936-1975 Finland, dictatorship 1939-1945 Italy, dictatorship (1922) Note that regimes which were not mentioned as dictatorships are not necessarily democratic either.
history.stackexchange.com/users/466/Anixx
Rather a lot of Western European countries spent the modern era vascilating between Democratic and Authoritarian governments.
This is common enough that it is common when talking about the modern history of said countries to refer to a period as either "The nth Republic" or "The nth Monarchy/Empire/Reich/Whatever".
Countries in this boat include Portugal, Spain, France, Germany, Italy, etc.
history.stackexchange.com/users/771/T.E.D.
I would characterize the 1973 overthrow of Chile's Salvador Allende by GENERAL Augosto Pinochet as an example of a "military takeover of a democracy in the western world."
http://en.wikipedia.org/wiki/Salvador_Allende Chile was a western democracy in 1973.
People might debate as to whether or not it was "advanced."
history.stackexchange.com/users/120/Tom Au
Ignoring the Spanish 1981 and Greek 1967 coups.  Are there any other examples of the military attempting (or even managing) to overthrow an elected government in an advanced democracy in the western world (W-Europe, Japan, Canada, USA)?  The only example I can remember reading about is the  1933 Business plot .  Another example is the Algerian coup against de Gaulle in 1961.
Has there ever been an attempted military takeover of a democracy in the western world?
history.stackexchange.com
<military><democracy>
history.stackexchange.com/questions/2721
history.stackexchange.com/users/1089/Karlth
There were many examples of this in South America such as the Pinochet coup in Chile in 1973. There was also the May coup in Poland. The most recent example of this might be the Pinochet coup in Chile in 1973. However, throughout recent and most distant past, there have been a number of coup attempts across Central and Southern America and Europe, including Poland, Spain and Finland.
Whilst there have been a number of examples of this in Central and South America, the most recent clear answer to this question would likely be the Pinochet coup in Chile in 1973 There have been a number of military coups across European countries both in recent and more distant past.