In the recent years, there has been a considerable increment of diffused generators connected to distribution grids by means of power converters. These converters operate frequently below their rated power due to the fluctuation of the power generated by the renewable sources. In this scenario, power electronics interfaces could be also used as active harmonic compensators for other converters or distorting loads. Typically, these converters do not have information on other loads or on the level of grid current distortion. For this reason, this paper presents a new control algorithm for the grid harmonics compensation that relies only on the measurement of the voltage at the point of connection of the power converter. The reference of the compensating current is calculated from the harmonic content of the voltage in a reference frame synchronous with the grid voltage. Simulation results carried out on a sample distribution network with linear and nonlinear loads show that the proposed method does not require the knowledge of the harmonic current either of the grid or of the load and it is suitable when the distorting loads are unknown.