Import of exchange rates from the NBU website to LibreOffice Calc


NBU_RATE() Description

A ready-made function for those who often have to use currency rates NBU in LibreOffice Calc .

Helps to automatically obtain the value of the exchange rate from NBU website by its code and date.

BASIC code for function NBU_RATE

To add a feature import exchange rates of the NBU , open the menu Tools - Macros - Edit Macros... , select Module1 and copy the following text into this module:

Function NBU_RATE(ByVal pCurrency, ByVal pDate)
  Dim FCalc As Object
  If Len(pCurrency) = 0 Or Len(pDate) = 0 Then Exit Function             
  FCalc = CreateUnoService("")
  tDate = FCalc.callFunction("TEXT", Array(pDate,"YYYYMMDD"))
  RequestString = "" & tDate & "&end=" & tDate & "&valcode=" & pCurrency
  WebServiceResponse = FCalc.callFunction("WEBSERVICE", Array(RequestString))  
  NBU_RATE = FCalc.callFunction("FILTERXML", Array(WebServiceResponse,"//rate_per_unit"))    
End Function

Close it Macro Editor and return to LibreOffice Calc .

Now you can manually enter our function NBU_RATE() . The syntax of this function is as follows:

=NBU_RATE ( currency code ; date )

We will have the following result:

Download the extension

You can use the NBURATE() function by installing a free extension YouLibreCalc.oxt or its full-featured version YLC_Utilities.oxt .

After that, this function will be available in all files that will be opened in LibreOffice Calc.